PHP & OOP - Image_Thumbnails

Oleg Butuzov

New member
I have write a small class for creating Thumbnails. I hope its will help somebody.

Any quetions in blog please. I am sorry but didnt yet translate my blog to english =(. I hope this litlle troubles would disturb you....=)

http://www.ua-design.net/blog/pear-image-thumbnails/
 
I think you should set the compression/quality as a variable (maybe even one passed to the constructor) as 60% is not going to be acceptable to most designers. For a static value I'd reccommend 85% or even 90

I also have a thumbnailing class being distributed from most of the class distro sites and from here.

Also note: rather than the mime_content_tyep and imagesx / imagesy calls, you could use getimagesize - the first index return is width, second is height and third is imagetype

so

Code:
$f_type = getimagesize($base_image);
$this->c_image = ($f_type[2] < 4)
                        ? ($f_type[2] < 3)
                            ? ($f_type[2] < 2)
                                ? ($f_type[2] < 1) ?
                                NULL
                            : imagecreatefromgif($base_image)
                        : imagecreatefromjpeg($base_image)
                    : imagecreatefrompng($base_image)
                    : NULL;
if($this->c_image !== NULL)
    {
    // $f_type[0] is width
    // $f_type[1] is height
 
permanent link
http://www.ua-design.net/blog/04.09.2003

as for get image type by getimagesize function. I prefer to use mime_content_type() =)
 
Back
Top