weikelbob
asked on
resampling image with GD LIbrary
What is the GD Library script to resample an image to 100 pixels tall in good quality?
ASKER
Great. Can I check to see if it's a GIF and do something else in that case? The max height should be 100px
Thanks.
Thanks.
You can use imagecreatefromgif and it works fine.
You can swap the $_dh and $_dw for the 100px height.
--brian
You can swap the $_dh and $_dw for the 100px height.
--brian
ASKER
How do I test to see if it's a gif or jpg, then run the appropriate script?
Thanks for the good script, BTW.
Thanks for the good script, BTW.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Brian,
I'm still implimenting this.
I'm still implimenting this.
$_src = imagecreatefromjpeg("C:\DS
if($_src) {
$_sw = imagesx($_src);
$_sh = imagesy($_src);
$_dw = 100; // Largest target dimension
$_dh = ($_sh / $_sw) * $_dw;
$_dest = imagecreatetruecolor($_dw,
imagecopyresampled($_dest,
imagejpeg($_dest, "c:\out.jpg", 75);
imagedestroy($_src);
imagedestroy($_dest);
}
?>