NYCPHP Meetup

NYPHP.org

[nycphp-talk] Image resizing/cropping on the fly

Federico Ulfo rainelemental at gmail.com
Wed Sep 7 12:33:49 EDT 2011


Hi guys,

I recently experienced an issue with the image resizing on the fly with GD
library of PHP.

I draw the image with:
header('Content-type :image/jpeg');
header('Content-Length: ' . filesize( $image ) );
$file = file_get_contents( $image );
echo $file;
it works when the image is already cached, when I've to create the image,
sometimes PHP change my header to Content-type: text/html, so the image
won't load, and I'll get instead a list of Ascii.

I fixed partially with a workaround, before do the *echo $file;* I check the
headers, if they are changed, I remove all of them and set again, also this
solution doesn't work always, I also tried to set header( "location: - same
location -" ); this works sometimes, because the cache is already created
but when there's many images sometimes the browser won't reindex it and give
again a blank image.

Do you have any idea of why does it?




 --
Federico Ulfo » <http://www.federicoulfo.it/>
Certified Developer Google & PHP
  <http://www.federicoulfo.it/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20110907/c09dbe75/attachment.html>


More information about the talk mailing list