Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
c7b3d2b4
Commit
c7b3d2b4
authored
Dec 29, 2013
by
Antonio Ramirez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
keep methods interface constant
parent
105a0bc4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
Image.php
extensions/yii/imagine/Image.php
+13
-11
No files found.
extensions/yii/imagine/Image.php
View file @
c7b3d2b4
...
@@ -148,16 +148,16 @@ class Image extends Component
...
@@ -148,16 +148,16 @@ class Image extends Component
* @param string $filename the full path to the image file
* @param string $filename the full path to the image file
* @param integer $width the crop width
* @param integer $width the crop width
* @param integer $height the crop height
* @param integer $height the crop height
* @param integer $
startX the x starting point
to crop from. Defaults to 0.
* @param integer $
x position on image
to crop from. Defaults to 0.
* @param integer $
startY the y starting point
to crop from. Defaults to 0.
* @param integer $
y position on image
to crop from. Defaults to 0.
* @return \Imagine\Image\ManipulatorInterface
* @return \Imagine\Image\ManipulatorInterface
*/
*/
public
function
crop
(
$filename
,
$width
,
$height
,
$
startX
=
0
,
$startY
=
0
)
public
function
crop
(
$filename
,
$width
,
$height
,
$
x
=
0
,
$y
=
0
)
{
{
return
$this
->
getImagine
()
return
$this
->
getImagine
()
->
open
(
$filename
)
->
open
(
$filename
)
->
copy
()
->
copy
()
->
crop
(
new
Point
(
$
startX
,
$startY
),
new
Box
(
$width
,
$height
));
->
crop
(
new
Point
(
$
x
,
$y
),
new
Box
(
$width
,
$height
));
}
}
/**
/**
...
@@ -169,7 +169,7 @@ class Image extends Component
...
@@ -169,7 +169,7 @@ class Image extends Component
* @param string $mode
* @param string $mode
* @return \Imagine\Image\ImageInterface|ManipulatorInterface
* @return \Imagine\Image\ImageInterface|ManipulatorInterface
*/
*/
public
function
thumb
(
$filename
,
$width
,
$height
,
$mode
=
ManipulatorInterface
::
THUMBNAIL_OUTBOUND
)
public
function
thumb
nail
(
$filename
,
$width
,
$height
,
$mode
=
ManipulatorInterface
::
THUMBNAIL_OUTBOUND
)
{
{
$box
=
new
Box
(
$width
,
$height
);
$box
=
new
Box
(
$width
,
$height
);
$img
=
$this
->
getImagine
()
$img
=
$this
->
getImagine
()
...
@@ -204,12 +204,14 @@ class Image extends Component
...
@@ -204,12 +204,14 @@ class Image extends Component
/**
/**
* Paste a watermark image onto another.
* Paste a watermark image onto another.
* Note: If any of `$x` or `$y` parameters are null, bottom right position will be default.
* @param string $filename the full path to the image file to apply the watermark to
* @param string $filename the full path to the image file to apply the watermark to
* @param string $watermarkFilename the full path to the image file to apply as watermark
* @param string $watermarkFilename the full path to the image file to apply as watermark
* @param Point $pos the pixel position where to apply the watermark. If null, bottomRight will be default.
* @param integer $x position on image to apply watermark. Defaults to null.
* @param integer $y position on image to apply watermark. Defaults to null
* @return ManipulatorInterface
* @return ManipulatorInterface
*/
*/
public
function
watermark
(
$filename
,
$watermarkFilename
,
Point
$pos
=
null
)
public
function
watermark
(
$filename
,
$watermarkFilename
,
$x
=
null
,
$y
=
null
)
{
{
$img
=
$this
->
getImagine
()
->
open
(
$filename
);
$img
=
$this
->
getImagine
()
->
open
(
$filename
);
$watermark
=
$this
->
getImagine
()
->
open
(
$watermarkFilename
);
$watermark
=
$this
->
getImagine
()
->
open
(
$watermarkFilename
);
...
@@ -217,10 +219,10 @@ class Image extends Component
...
@@ -217,10 +219,10 @@ class Image extends Component
$size
=
$img
->
getSize
();
$size
=
$img
->
getSize
();
$wSize
=
$watermark
->
getSize
();
$wSize
=
$watermark
->
getSize
();
// if
no Point position was
given, set its bottom right by default
// if
x or y position was not
given, set its bottom right by default
$pos
=
$
pos
===
null
?
$pos
=
$
x
===
null
||
$y
===
null
new
Point
(
$size
->
getWidth
()
-
$wSize
->
getWidth
()
,
$size
->
getHeight
()
-
$wSize
->
getHeight
())
?
new
Point
(
$size
->
getWidth
()
-
$wSize
->
getWidth
()
,
$size
->
getHeight
()
-
$wSize
->
getHeight
())
:
$pos
;
:
new
Point
(
$x
,
$y
)
;
return
$img
->
paste
(
$watermark
,
$pos
);
return
$img
->
paste
(
$watermark
,
$pos
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment