Jump to content

Need a Content-Length header for a Dynamically Resized Image


BioBob

Recommended Posts

So I have a script that resizes images for thumbnails to a default size.  But I also need to send a Content-Length header for the resized file size.  getimagesize only works on files, not on recently generated stuff.  How do I get the file size of the image to be sent to the browser?

 

$img = imagecreatefromjpeg($file);
$image_stats = getimagesize($file);  //GDLib
$image_width = $image_stats[0];     //width 
$image_height = $image_stats[1];    //height 

$size = 100;

$new_h = $size; 
$ratio = ($image_height / $new_h); 
$new_w = round($image_width / $ratio); 

$dst_img = ImageCreateTrueColor($new_w,$new_h);
imagecopyresampled ($dst_img,$img,0,0,0,0,$new_w,$new_h,$image_width,$image_height);

imagejpeg($dst_img);
imagedestroy($dst_img); 
imagedestroy($img);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.