Forum Moderators: coopster

Message Too Old, No Replies

using exif thumbnail() to resize

using exif_thumbnail() to resize

         

Sonnenblume

4:09 pm on Aug 14, 2007 (gmt 0)

10+ Year Member



Hi there, im wanting to use the function exif_thumbnail() to resize a thumnail on my screen. I can get the thumbnail to display okay, but it doesnt resize in accordence with the paramters ive passed it. Any suggestions?

using exif_thumbnail() to resize

<?php
$width='400';
$height='200';
$type="jpg";
$image = exif_thumbnail('1.jpg', $width, $height, $type);
header("Content-Type: image/jpeg");
echo $image;
?>

jatar_k

4:11 pm on Aug 14, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



are you using IE? is it resizing it for you?

check the properties to see what the actual dimensions are

terencepae

4:19 pm on Aug 14, 2007 (gmt 0)

10+ Year Member



use ajax or javascript.. it works better.

whoisgregg

9:24 pm on Aug 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



exif_thumbnail [php.net] only retrieves the thumbnail already embedded in the file and returns it's current size. It doesn't actually create the thumbnail or edit it's size.

To get a specific size, you can either style it using CSS to a specific size (result may be pixelated in some browsers, notably IE):

echo '<img src="'.$image_path.'" style="width: '.$new_width.'px; height: '.$new_height.'px;" />

Or, you need to actually generate the image smaller using the image functions [us.php.net], particularly imagecopyresampled [php.net].

henry0

9:37 pm on Aug 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You will be better off using Greg's GD() suggestions
remember that simply hard coding a new image W and H size does not modify/deal with the original image file so your BW consumption will be the same.
it is not a server side move but a client side
for ex: if your img is 600k and width=600
even served client side and making it 10 px wide will still call the 600k original img