PHP (class.upload.php): Resize picture depending on Width and Height -



PHP (class.upload.php): Resize picture depending on Width and Height -

i'm using class class.upload.php resize , upload images. images need exact 770x400.

this i'm trying accomplish:

1) upload image - done

2) resize image width 770px or height 400px

3) cutting image 770x400 using visual cutter (jcrop image) - done

i'm struggling 2nd point don't know how recognize image proportion.

example: if image has width 2156px , height 777px need resized height: 400px give 1100x400

if image has width 777px , height 2156px need resized width: 770px give 770x2137

how recognize image proportion?

to resize width i'm using class.upload.php parameters:

$handle->image_resize = true; $handle->image_ratio_y = true; $handle->image_x = 770;

to resize height i'm using:

$handle->image_resize = true; $handle->image_ratio_x = true; $handle->image_y = 400;

think found reply myself.

list($read_w, $read_h, $type, $attr)= getimagesize($_files['file']); $oryginalimage_ratio=$read_w/$read_h; $desiredimage_ratio=770/400; if($oryginalimage_ratio>$desiredimage_ratio){ $handle->image_resize = true; $handle->image_ratio_y = true; $handle->image_x = 770; }else{ $handle->image_resize = true; $handle->image_ratio_x = true; $handle->image_y = 400; }

php resize-image

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -