[nycphp-talk] Image resizing/cropping on the fly
Federico Ulfo
rainelemental at gmail.com
Wed Sep 7 12:54:29 EDT 2011
True that, but the error happen randomly, the same image sometimes works
sometimes no, so I think it might be some GD library bug
--
Federico Ulfo » <http://www.federicoulfo.it/>
Certified Developer Google & PHP
<http://www.federicoulfo.it/>
On Wed, Sep 7, 2011 at 12:43 PM, Jake McGraw <jmcgraw1 at gmail.com> wrote:
> If any of the following causes an error and display_errors == 1, you'll get
> output and PHP will default to text/html:
>
> header('Content-type :image/jpeg');
> header('Content-Length: ' . filesize( $image ) );
> $file = file_get_contents( $image );
>
> If you have any whitespace prior to header(), you'll get output and PHP
> will default to text/html.
>
> You can avoid whitespace by never using an ending ?> tag.
>
> Jake
>
> On Wed, Sep 7, 2011 at 12:33 PM, Federico Ulfo <rainelemental at gmail.com>wrote:
>
>> 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/>
>>
>>
>> _______________________________________________
>> New York PHP Users Group Community Talk Mailing List
>> http://lists.nyphp.org/mailman/listinfo/talk
>>
>> http://www.nyphp.org/Show-Participation
>>
>
>
> _______________________________________________
> New York PHP Users Group Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> http://www.nyphp.org/Show-Participation
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20110907/21277ab4/attachment.html>
More information about the talk
mailing list