aliroImage Class Reference

List of all members.

Public Member Functions

 __construct ($path)
 imgresize ($new_width, $new_height)
 saveAs ($path, $highQuality=false)

Private Attributes

 $path = ''
 $image = null


Detailed Description

Definition at line 3 of file aliroImage.php.


Constructor & Destructor Documentation

aliroImage::__construct ( path  ) 

Definition at line 7 of file aliroImage.php.

References $path, and T_().

00007                                         {
00008         $this->path = $path;
00009         $info = pathinfo($path);
00010         $type = $info['extension'];
00011         if ('jpg' == $type OR 'jpeg' == $type) $this->image = imagecreatefromjpeg($path);
00012         elseif ('png' == $type) $this->image = imagecreatefrompng($path);
00013         elseif ('gif' == $type) $this->image = imagecreatefromgif($path);
00014         else trigger_error (T_('Class aliroImage create - path has invalid extension - not jpg, jpeg, gif, png'), E_USER_ERROR);
00015     }


Member Function Documentation

aliroImage::imgresize ( new_width,
new_height 
)

Definition at line 19 of file aliroImage.php.

References T_().

00019                                                         {
00020         if (!$this->image) trigger_error (T_('Class aliroImage resize - no valid image created'), E_USER_ERROR);
00021         //grab original sizes
00022         $old_x=imagesx($this->image);
00023         $old_y=imagesy($this->image);
00024 
00025         // new math to figure aspect ratio
00026         $ratio = min($new_width/$old_x, $new_height/$old_y);
00027         $new_height = $old_y * $ratio;
00028         $new_width = $old_x * $ratio;
00029 
00030         //generate a blank final image
00031         $dst_img=ImageCreateTrueColor($new_width, $new_height);
00032 
00033         //this resamples the original image and I think uses bicub to create a new image
00034         imagecopyresampled($dst_img, $this->image, 0, 0, 0, 0, $new_width, $new_height, $old_x, $old_y);
00035     }

aliroImage::saveAs ( path,
highQuality = false 
)

Definition at line 37 of file aliroImage.php.

References $path, aliroFileManager::getInstance(), and T_().

00037                                                        {
00038         if (!$this->image) trigger_error (T_('Class aliroImage save - no valid image created'), E_USER_ERROR);
00039         //unlink it if it already exists in destination
00040         $info = pathinfo($path);
00041         $exts = array('jpg', 'jpeg', 'png', 'gif');
00042         if (in_array($info['extension'], $exts) {
00043             aliroFileManager::getInstance()->deleteFile($path);
00044             switch ($info['extension']) {
00045                 case 'jpg':
00046                 case 'jpeg':
00047                     if ($highQuality) imagejpeg($this->image, $path, 100);
00048                     else imagejpeg($this->image, $path);
00049                     break;
00050                 case 'png':
00051                     if ($highQuality) imagepng($this->image, $path, 0);
00052                     else imagepng($this->image, $path);
00053                     break;
00054                 case 'gif':
00055                     imagegif($this->image, $path);
00056                     break;
00057             }
00058         }       
00059         else trigger_error(T_('Class aliroImage save method - path has wrong extension'), E_USER_ERROR);
00060     }


Member Data Documentation

aliroImage::$path = '' [private]

Definition at line 4 of file aliroImage.php.

Referenced by __construct(), and saveAs().

aliroImage::$image = null [private]

Definition at line 5 of file aliroImage.php.


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

Generated on Thu Apr 17 13:03:30 2008 for ALIRO by  doxygen 1.5.5