PHP Classes

Different images, different path

Recommend this page to a friend!

      Easy Resize Image  >  All threads  >  Different images, different path  >  (Un) Subscribe thread alerts  
Subject:Different images, different path
Summary:Add new functionality to the class
Messages:2
Author:Konstantin
Date:2009-02-05 10:09:06
Update:2009-02-07 10:46:13
 

  1. Different images, different path   Reply   Report abuse  
Picture of Konstantin Konstantin - 2009-02-05 10:09:06
Hi, your class is nice.
But I need to load different photos from different localions.
I need something like this:
src=image.php?photo=my_house&mime=jpg&path=images&subpath=data&thumb=400

to resize photo from www.my_site.ru/images/data/my_house.jpg

2. There is one problem in the resise method like that:
browser do not know about width & height of loading photo. And load html page widhout photos, after that redraw design with pictures:

img src=my_home.jpg width=100 height=80 alt=house
or
src=image.php&thumb=400 --- in that case there is not attributes w and h

Thanks!

  2. Re: Different images, different path   Reply   Report abuse  
Picture of László Zsidi László Zsidi - 2009-02-07 10:46:13 - In reply to message 1 from Konstantin
Hi,

First of all, the 'thumb' size is not w & h size, this value is a reference value to decrease the image dimension with aspect ratio.
You can use two differences photo types, landscapes and portrait.
The photo is landscape when, if the width of the image is bigger than the height of the image and photo is portarit when, if the height of the image is bigger than the width of the image.
The resize class will be create a new dimension by the 'thumb' value and the w & h attributes /portait or landscape/ and resize image.

Of course you can use this class with a minimal modify:

<?php
/*
*
* => Example Start
*
*/
include "resizeImage.class.php";
/*
*
* => Class constructor
*
*/
$resizeimage = new resizeImage;
/*
*
* => Add image path and new thumb size
*
*/
$full_path = "/" . $_GET [ 'path' ] . "/" . $_GET [ 'subpath' ] . "/" .$_GET [ 'photo' ] . $_GET [ 'mime' ];
$image = $resizeimage -> process ( $full_path, isset ( $_GET [ 'thumb' ] ) ? $_GET [ 'thumb' ] : 90 );
/*
*
* => Set image header
*
*/
header ( 'Content-type:image/' . $_GET [ 'mime' ] );
/*
*
* => Create image
*
*/
switch ( strtolower ( $_GET [ 'mime' ] ) ) {
case "jpeg":
imageJpeg ( $image );
break;
case "jpg":
imageJpeg ( $image );
break;
case "png":
imagePng ( $image );
break;
case "gif":
imageGif ( $image );
break;
}
/*
*
* => Destroy image
*
*/
imageDestroy ( $image );
/*
*
* => Example End
*
*/
?>