Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy would a PHP image copy and resize script cause a browser to return "Content Encoding Error"?
    primarykey
    data
    text
    <p>I have a PHP script that takes an images, checks type and filesize, then creates 2 resized copies of the master image, all 3 images are saved to the server. I was under the impression everything worked fine. I was testing out script and on one jpg image I got thrown the error "Content Encoding Error" by firefox. Doing some reading suggested this was a Firefox issue but testing in IE and Chrome resulted in similar errors.</p> <p>The odd thing is that some .jpg files work, others don't. For those that don't work the error is occurring when the script comes to encode the second resized copy as the master, and first copy are outputted to specified folder. I have checked to see that the image itself isn't corrupt after doing some more reading. The only difference I could note between a .jpg that would allow the script to complete fully and one that wouldn't was that, when viewing the properties of the failing one within Windows it appeared to carry more data, such as camera used to, model number, etc.</p> <p>Does anyone know what might be causing this error to be thrown?</p> <p>EDIT</p> <p>Here's the code I'm using.</p> <pre><code>$imgsrc = imagecreatefromjpeg($file); imagecopyresampled($thbout,$imgsrc,0,0,0,0,$thbwid,$thbhei,$width,$height); imagejpeg($thbout,$thbpath,80); imagedestroy($thbout); imagecopyresampled($optout,$imgsrc,0,0,0,0,$optwid,$opthei,$width,$height); imagejpeg($optout,$optpath,80); imagedestroy($optout); </code></pre> <p>Having played about a bit tonight I got it working, by switching the code to this. (Switch to create larger file first)</p> <pre><code>$imgsrc = imagecreatefromjpeg($file); imagecopyresampled($optout,$imgsrc,0,0,0,0,$optwid,$opthei,$width,$height); imagejpeg($optout,$optpath,80); imagedestroy($optout); imagecopyresampled($thbout,$imgsrc,0,0,0,0,$thbwid,$thbhei,$width,$height); imagejpeg($thbout,$thbpath,80); imagedestroy($thbout); </code></pre> <p>So I guess my new question becomes, why does it behave like this? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload