Varien_Image Class Reference

List of all members.

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


Detailed Description

Definition at line 34 of file Image.php.


Constructor & Destructor Documentation

__construct ( fileName = null,
adapter = Varien_Image_Adapter::ADAPTER_GD2 
)

Constructor

Parameters:
Varien_Image_Adapter $adapter. Default value is GD2
string $fileName
Returns:
void

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     }


Member Function Documentation

_getAdapter ( adapter = null  )  [protected]

Retrieve image adapter object

Parameters:
string $adapter
Returns:
Varien_Image_Adapter_Abstract

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.

Parameters:
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
Returns:
void

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

Returns:
void

Definition at line 79 of file Image.php.

00080     {
00081         $this->_getAdapter()->display();
00082     }

getMimeType (  ) 

Get mime type of handled image

public

Returns:
string

Definition at line 188 of file Image.php.

00189     {
00190         return $this->_getAdapter()->getMimeType();
00191     }

getOriginalHeight (  ) 

Retrieve original image height

Returns:
int|null

Definition at line 274 of file Image.php.

00275     {
00276         return $this->_getAdapter()->getOriginalHeight();
00277     }

getOriginalWidth (  ) 

Retrieve original image width

Returns:
int|null

Definition at line 264 of file Image.php.

00265     {
00266         return $this->_getAdapter()->getOriginalWidth();
00267     }

instruction (  ) 

instruction

public

Returns:
void

Definition at line 210 of file Image.php.

00211     {
00212 
00213     }

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

Returns:
void

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 (  ) 

process

public

Returns:
void

Definition at line 199 of file Image.php.

00200     {
00201 
00202     }

resize ( width,
height = null 
)

Resize an image

Parameters:
int $width
int $height public
Returns:
void

Definition at line 132 of file Image.php.

00133     {
00134         $this->_getAdapter()->resize($width, $height);
00135     }

rotate ( angle  ) 

Rotate an image.

Parameters:
int $angle public
Returns:
void

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

Parameters:
string $destination. Default value is NULL
string $newFileName. Default value is NULL public
Returns:
void

Definition at line 92 of file Image.php.

00093     {
00094         $this->_getAdapter()->save($destination, $newFileName);
00095     }

setImageBackgroundColor ( color  ) 

Set image background color

Parameters:
int $color public
Returns:
void

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.

Parameters:
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
Returns:
void

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     }


Member Data Documentation

$_adapter [protected]

Definition at line 36 of file Image.php.

$_fileName [protected]

Definition at line 38 of file Image.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:25:03 2009 for Magento by  doxygen 1.5.8