Login   Register  
PHP Classes
elePHPant
Icontem

File: ImageResizeFactory.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Sujay Bhowmick  >  Image Resize Class  >  ImageResizeFactory.php  >  Download  
File: ImageResizeFactory.php
Role: Class source
Content type: text/plain
Description: Factory Method class
Class: Image Resize Class
Resize image from files in different formats
Author: By
Last change: added end function to check on extension array. So that the files having multiple "." are handled.
if(preg_match("/jpg|JPG|jpeg|JPEG/", end($extension)))
Date: 10 years ago
Size: 856 bytes
 

Contents

Class file image Download
<?php
include_once("ImageResizeClass.php");

/**
* class ImageResizeFactory
*
* { Description :- 
*    This Class is a factory method class which returns the appropriate object of ImageResizeClass depending on the type of Image 
*    i.e jpg or Png.
* }
*/

class ImageResizeFactory
{
    
/**
    * Method ImageResizeFactory::getInstanceOf()
    *
    * { Description :- 
    *    This method resizes the image.
    * }
    */
    
    
function getInstanceOf($imageName$resizedImageName$newWidth$newHeight)
    {
        
$extension explode("."$imageName);
        if(
preg_match("/jpg|JPG|jpeg|JPEG/"end($extension)))
        {
            return new 
ImageResizeJpeg($imageName$resizedImageName$newWidth$newHeight);
        }
        elseif(
preg_match("/png|PNG/"end($extension)))
        {
            return new 
ImageResizePng($imageName$resizedImageName$newWidth$newHeight);
        }
    }
}
?>