Public Member Functions | |
__construct ($fileName=null, $adapter=Varien_Image_Adapter::ADAPTER_GD2) | |
open () | |
display () | |
save ($destination=null, $newFileName=null) | |
rotate ($angle) | |
crop ($top=0, $left=0, $right=0, $bottom=0) | |
resize ($width, $height=null) | |
keepAspectRatio ($value) | |
keepFrame ($value) | |
keepTransparency ($value) | |
constrainOnly ($value) | |
backgroundColor ($value) | |
watermark ($watermarkImage, $positionX=0, $positionY=0, $watermarkImageOpacity=30, $repeat=false) | |
getMimeType () | |
process () | |
instruction () | |
setImageBackgroundColor ($color) | |
setWatermarkPosition ($position) | |
setWatermarkWidth ($width) | |
setWatermarkHeigth ($heigth) | |
getOriginalWidth () | |
getOriginalHeight () | |
Protected Member Functions | |
_getAdapter ($adapter=null) | |
Protected Attributes | |
$_adapter | |
$_fileName |
Definition at line 34 of file Image.php.
__construct | ( | $ | fileName = null , |
|
$ | adapter = Varien_Image_Adapter::ADAPTER_GD2 | |||
) |
Constructor
Varien_Image_Adapter | $adapter. Default value is GD2 | |
string | $fileName |
Definition at line 47 of file Image.php.
00048 { 00049 $this->_getAdapter($adapter); 00050 $this->_fileName = $fileName; 00051 if( isset($fileName) ) { 00052 $this->open(); 00053 } 00054 }
_getAdapter | ( | $ | adapter = null |
) | [protected] |
Retrieve image adapter object
string | $adapter |
Definition at line 251 of file Image.php.
00252 { 00253 if( !isset($this->_adapter) ) { 00254 $this->_adapter = Varien_Image_Adapter::factory( $adapter ); 00255 } 00256 return $this->_adapter; 00257 }
backgroundColor | ( | $ | value | ) |
Definition at line 157 of file Image.php.
00158 { 00159 return $this->_getAdapter()->backgroundColor($value); 00160 }
constrainOnly | ( | $ | value | ) |
Definition at line 152 of file Image.php.
00153 { 00154 return $this->_getAdapter()->constrainOnly($value); 00155 }
crop | ( | $ | top = 0 , |
|
$ | left = 0 , |
|||
$ | right = 0 , |
|||
$ | bottom = 0 | |||
) |
Crop an image.
int | $top. Default value is 0 | |
int | $left. Default value is 0 | |
int | $right. Default value is 0 | |
int | $bottom. Default value is 0 public |
Definition at line 119 of file Image.php.
00120 { 00121 $this->_getAdapter()->crop($left, $top, $right, $bottom); 00122 }
display | ( | ) |
Display handled image in your browser
public
Definition at line 79 of file Image.php.
00080 { 00081 $this->_getAdapter()->display(); 00082 }
getMimeType | ( | ) |
Get mime type of handled image
public
Definition at line 188 of file Image.php.
00189 { 00190 return $this->_getAdapter()->getMimeType(); 00191 }
getOriginalHeight | ( | ) |
Retrieve original image height
Definition at line 274 of file Image.php.
00275 { 00276 return $this->_getAdapter()->getOriginalHeight(); 00277 }
getOriginalWidth | ( | ) |
Retrieve original image width
Definition at line 264 of file Image.php.
00265 { 00266 return $this->_getAdapter()->getOriginalWidth(); 00267 }
instruction | ( | ) |
keepAspectRatio | ( | $ | value | ) |
Definition at line 137 of file Image.php.
00138 { 00139 return $this->_getAdapter()->keepAspectRatio($value); 00140 }
keepFrame | ( | $ | value | ) |
Definition at line 142 of file Image.php.
00143 { 00144 return $this->_getAdapter()->keepFrame($value); 00145 }
keepTransparency | ( | $ | value | ) |
Definition at line 147 of file Image.php.
00148 { 00149 return $this->_getAdapter()->keepTransparency($value); 00150 }
open | ( | ) |
Opens an image and creates image handle
public
Definition at line 62 of file Image.php.
00063 { 00064 $this->_getAdapter()->checkDependencies(); 00065 00066 if( !file_exists($this->_fileName) ) { 00067 throw new Exception("File '{$this->_fileName}' does not exists."); 00068 } 00069 00070 $this->_getAdapter()->open($this->_fileName); 00071 }
process | ( | ) |
resize | ( | $ | width, | |
$ | height = null | |||
) |
Resize an image
int | $width | |
int | $height public |
Definition at line 132 of file Image.php.
00133 { 00134 $this->_getAdapter()->resize($width, $height); 00135 }
rotate | ( | $ | angle | ) |
Rotate an image.
int | $angle public |
Definition at line 104 of file Image.php.
00105 { 00106 $this->_getAdapter()->rotate($angle); 00107 }
save | ( | $ | destination = null , |
|
$ | newFileName = null | |||
) |
Save handled image into file
string | $destination. Default value is NULL | |
string | $newFileName. Default value is NULL public |
Definition at line 92 of file Image.php.
00093 { 00094 $this->_getAdapter()->save($destination, $newFileName); 00095 }
setImageBackgroundColor | ( | $ | color | ) |
Set image background color
int | $color public |
Definition at line 222 of file Image.php.
00223 { 00224 $this->_getAdapter()->imageBackgroundColor = intval($color); 00225 }
setWatermarkHeigth | ( | $ | heigth | ) |
Definition at line 239 of file Image.php.
00240 { 00241 $this->_getAdapter()->setWatermarkHeigth($heigth); 00242 return $this; 00243 }
setWatermarkPosition | ( | $ | position | ) |
Definition at line 227 of file Image.php.
00228 { 00229 $this->_getAdapter()->setWatermarkPosition($position); 00230 return $this; 00231 }
setWatermarkWidth | ( | $ | width | ) |
Definition at line 233 of file Image.php.
00234 { 00235 $this->_getAdapter()->setWatermarkWidth($width); 00236 return $this; 00237 }
watermark | ( | $ | watermarkImage, | |
$ | positionX = 0 , |
|||
$ | positionY = 0 , |
|||
$ | watermarkImageOpacity = 30 , |
|||
$ | repeat = false | |||
) |
Adds watermark to our image.
string | $watermarkImage. Absolute path to watermark image. | |
int | $positionX. Watermark X position. | |
int | $positionY. Watermark Y position. | |
int | $watermarkImageOpacity. Watermark image opacity. | |
bool | $repeat. Enable or disable watermark brick. public |
Definition at line 174 of file Image.php.
00175 { 00176 if( !file_exists($watermarkImage) ) { 00177 throw new Exception("Required file '{$watermarkImage}' does not exists."); 00178 } 00179 $this->_getAdapter()->watermark($watermarkImage, $positionX, $positionY, $watermarkImageOpacity, $repeat); 00180 }