Public Member Functions | |
load (Mage_Media_Model_Image $object, $file, $field=null) | |
save (Mage_Media_Model_Image $object) | |
delete (Mage_Media_Model_Image $object) | |
getImage (Mage_Media_Model_Image $object) | |
getTmpImage (Mage_Media_Model_Image $object) | |
resize (Mage_Media_Model_Image $object) | |
watermark (Mage_Media_Model_Image $object) | |
saveAs (Mage_Media_Model_Image $object, $extension=null) | |
getDimensions (Mage_Media_Model_Image $object) | |
destroyResource (&$resource) | |
hasSpecialImage (Mage_Media_Model_Image $object) | |
Protected Member Functions | |
_construct () | |
_getReadAdapter () | |
_getWriteAdapter () |
Definition at line 35 of file Image.php.
_construct | ( | ) | [protected] |
Resource initialization
Reimplemented from Mage_Core_Model_Resource_Abstract.
Definition at line 40 of file Image.php.
_getReadAdapter | ( | ) | [protected] |
Retrieve connection for read data
Reimplemented from Mage_Core_Model_Resource_Abstract.
Definition at line 48 of file Image.php.
_getWriteAdapter | ( | ) | [protected] |
Retrieve connection for write data
Reimplemented from Mage_Core_Model_Resource_Abstract.
Definition at line 56 of file Image.php.
delete | ( | Mage_Media_Model_Image $ | object | ) |
destroyResource | ( | &$ | resource | ) |
getDimensions | ( | Mage_Media_Model_Image $ | object | ) |
Retrive image dimensions
Mage_Media_Model_Image | $object |
Definition at line 197 of file Image.php.
00198 { 00199 $info = @getimagesize($object->getFilePath()); 00200 if(!$info) { 00201 Mage::throwException(Mage::helper('media')->__('Image not exists or invalid')); 00202 } 00203 00204 $info = array('width'=>$info[0], 'height'=>$info[1], 'type'=>$info[2]); 00205 return new Varien_Object($info); 00206 }
getImage | ( | Mage_Media_Model_Image $ | object | ) |
Create image resource for operation from file
Mage_Media_Model_Image | $object |
Definition at line 84 of file Image.php.
00085 { 00086 $resource = false; 00087 switch(strtolower($object->getExtension())) { 00088 case 'jpg': 00089 case 'jpeg': 00090 $resource = imagecreatefromjpeg($object->getFilePath()); 00091 break; 00092 00093 case 'gif': 00094 $resource = imagecreatefromgif($object->getFilePath()); 00095 break; 00096 00097 case 'png': 00098 $resource = imagecreatefrompng($object->getFilePath()); 00099 break; 00100 } 00101 00102 if(!$resource) { 00103 Mage::throwException(Mage::helper('media')->__('Image not exists or invalid')); 00104 } 00105 00106 00107 return $resource; 00108 }
getTmpImage | ( | Mage_Media_Model_Image $ | object | ) |
Create tmp image resource for operations
Mage_Media_Model_Image | $object |
Definition at line 116 of file Image.php.
00117 { 00118 $resource = imagecreatetruecolor($object->getDestanationDimensions()->getWidth(), $object->getDestanationDimensions()->getHeight()); 00119 return $resource; 00120 }
hasSpecialImage | ( | Mage_Media_Model_Image $ | object | ) |
load | ( | Mage_Media_Model_Image $ | object, | |
$ | file, | |||
$ | field = null | |||
) |
resize | ( | Mage_Media_Model_Image $ | object | ) |
Resize image
Mage_Media_Model_Image | $object |
Definition at line 128 of file Image.php.
00129 { 00130 $tmpImage = $object->getTmpImage(); 00131 $sourceImage = $object->getImage(); 00132 00133 imagecopyresampled( 00134 $tmpImage, 00135 $sourceImage, 00136 0, 0, 0, 0, 00137 $object->getDestanationDimensions()->getWidth(), 00138 $object->getDestanationDimensions()->getHeight(), 00139 $object->getDimensions()->getWidth(), 00140 $object->getDimensions()->getHeight() 00141 ); 00142 00143 return $this; 00144 }
save | ( | Mage_Media_Model_Image $ | object | ) |
saveAs | ( | Mage_Media_Model_Image $ | object, | |
$ | extension = null | |||
) |
Creates image
Mage_Media_Model_Image | $object | |
string|null | $extension |
Definition at line 164 of file Image.php.
00165 { 00166 if(is_null($extension)) { 00167 $extension = $object->getExtension(); 00168 } 00169 00170 $result = false; 00171 switch (strtolower($extension)) { 00172 case 'jpg': 00173 case 'jpeg': 00174 $result = imagejpeg($object->getTmpImage(), $object->getFilePath(true), 80); 00175 break; 00176 case 'gif': 00177 $result = imagegif($object->getTmpImage(), $object->getFilePath(true)); 00178 break; 00179 case 'png': 00180 $result = imagepng($object->getTmpImage(), $object->getFilePath(true)); 00181 break; 00182 } 00183 00184 if(!$result) { 00185 Mage::throwException(Mage::helper('media')->__('Error while creating image')); 00186 } 00187 00188 return $this; 00189 }
watermark | ( | Mage_Media_Model_Image $ | object | ) |
Add watermark for image
Mage_Media_Model_Image | $object |
Definition at line 152 of file Image.php.