Preventing 'image corrupt or truncated' error

by graham

Image corrupt or truncated error in Firebug

Since Firefox 4 rolled out and Firebug was updated a new error appeared, even on projects that had previously been error free. Then I started seeing the error:

    Image corrupt or truncated: <unknown>

This would usually only appear on localhost but what was strange was that there was no reference to a file or line that the error was coming from - essentially making it impossible to debug. 

Initially I put this down to the few know issues with Firebug 1.7 and FF4 then later found it started to appear when I added a favicon to a site (with or without the <link> reference). 

Corrupted image

What causes this error is actually a correct response in reading an image that has had it's extension changed from it's original saved format. 

In the same way that changing a jpeg's extension to ".gif" doesn't make it a gif, giving a png a ".ico" extension doesn't make it an icon file. 

Opening the file in an image editor that can recognise Windows Icon files, such as Irfanview, also highlights that the extension is wrong;

 

Renaming the image and then re-saving it as an ICO - Windows Icon file gives you a correctly formatted image and stops Firefox throwing an error. 

Comments

June 23. 2011 #

Didn't work for me.  When I opened the file in irfanView, the message popped up and irfanView generated a .png file for me.  I took that file into photoshop (and irfanView) in an attempt to generate the image correctly with the .ico extension...but it didn't work.  I tried several times to no avail...

LeroyV United States |

June 27. 2011 #

Hi Leroy

How are you creating images with the .ico extension?

You need to save the favicon out as an ico file, so in Irfan View choose "Save as type: ICO - Windows Icon" in the save as options.

graham United Kingdom |

Comments are closed