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
105a0bc4
Commit
105a0bc4
authored
Dec 28, 2013
by
Antonio Ramirez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added frame method
parent
6e2e11c3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
7 deletions
+37
-7
Image.php
extensions/yii/imagine/Image.php
+37
-7
No files found.
extensions/yii/imagine/Image.php
View file @
105a0bc4
...
@@ -115,7 +115,11 @@ class Image extends Component
...
@@ -115,7 +115,11 @@ class Image extends Component
*/
*/
public
function
getAvailableDrivers
()
public
function
getAvailableDrivers
()
{
{
return
[
static
::
DRIVER_GD2
,
static
::
DRIVER_GMAGICK
,
static
::
DRIVER_IMAGICK
];
static
$drivers
;
if
(
$drivers
===
null
)
{
$drivers
=
[
static
::
DRIVER_GD2
,
static
::
DRIVER_GMAGICK
,
static
::
DRIVER_IMAGICK
];
}
return
$drivers
;
}
}
/**
/**
...
@@ -142,10 +146,10 @@ class Image extends Component
...
@@ -142,10 +146,10 @@ class Image extends Component
/**
/**
* Crops an image
* Crops an image
* @param string $filename the full path to the image file
* @param string $filename the full path to the image file
* @param int $width the crop width
* @param int
eger
$width the crop width
* @param int $height the crop height
* @param int
eger
$height the crop height
* @param int $startX the x starting point to crop from. Defaults to 0.
* @param int
eger
$startX the x starting point to crop from. Defaults to 0.
* @param int $startY the y starting point to crop from. Defaults to 0.
* @param int
eger
$startY the y starting point 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
,
$startX
=
0
,
$startY
=
0
)
...
@@ -160,8 +164,8 @@ class Image extends Component
...
@@ -160,8 +164,8 @@ class Image extends Component
* Creates a thumbnail image. The function differs from [[\Imagine\Image\ImageInterface::thumbnail()]] function that
* Creates a thumbnail image. The function differs from [[\Imagine\Image\ImageInterface::thumbnail()]] function that
* it keeps the aspect ratio of the image.
* it keeps the aspect ratio of the image.
* @param string $filename the full path to the image file
* @param string $filename the full path to the image file
* @param int $width the width to create the thumbnail
* @param int
eger
$width the width to create the thumbnail
* @param int $height the height in pixels to create the thumbnail
* @param int
eger
$height the height in pixels to create the thumbnail
* @param string $mode
* @param string $mode
* @return \Imagine\Image\ImageInterface|ManipulatorInterface
* @return \Imagine\Image\ImageInterface|ManipulatorInterface
*/
*/
...
@@ -253,4 +257,29 @@ class Image extends Component
...
@@ -253,4 +257,29 @@ class Image extends Component
$img
->
draw
()
->
text
(
$text
,
$font
,
new
Point
(
$fontPosX
,
$fontPosY
),
$fontAngle
);
$img
->
draw
()
->
text
(
$text
,
$font
,
new
Point
(
$fontPosX
,
$fontPosY
),
$fontAngle
);
return
$img
;
return
$img
;
}
}
/**
* Adds a frame around of the image. Please note that the image will increase `$margin` x 2.
* @param string $filename the full path to the image file
* @param integer $margin the frame size to add around the image
* @param string $color the frame color
* @param integer $alpha
* @return \Imagine\Image\ImageInterface
*/
public
function
frame
(
$filename
,
$margin
,
$color
=
'000'
,
$alpha
=
100
)
{
$img
=
$this
->
getImagine
()
->
open
(
$filename
);
$size
=
$img
->
getSize
();
$pasteTo
=
new
Point
(
$margin
,
$margin
);
$padColor
=
new
Color
(
$color
,
$alpha
);
$box
=
new
Box
(
$size
->
getWidth
()
+
ceil
(
$margin
*
2
),
$size
->
getHeight
()
+
ceil
(
$margin
*
2
));
$image
=
$this
->
getImagine
()
->
create
(
$box
,
$padColor
);
$image
->
paste
(
$img
,
$pasteTo
);
return
$image
;
}
}
}
\ No newline at end of file
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