php image upload help
- Started
- Last post
- 3 Responses
- silentseven
is there a way I can make a script tell if an image is portrait or landscape based on the pixel dimension to resize to thubnail specs accordingly?
So if the image is landscape at full size it changes to 150 x 50 and if it is portrait than resize to 50 x 150
- root_lock0
you can use
http://ca.php.net/getimagesize
find the ratio by dividing the height and width . then a if else statement with the ratio.
- cosmo0
you can use the gd library to resize.
use this to resize jpeg's:
$imgPath = "yourdomain.com";
$fixedImageName = "something.jpg";$src_img = imagecreatefromjpeg($imgPath.$fi...
$origw = imagesx($src_img);
$origh = imagesy($src_img);
$new_w = 150; // resize to 100px wide
$diff = $origw/$new_w;
$new_h = 50;$dst_img = imagecreate($new_w,$new_h);
imagecopyresized($dst_img,$src_i...
imagejpeg($dst_img, $imgPath.$fixedThumbnailName
- silentseven0
perfect... thanks