9
May

Image Load I/O Error in Flex

On a project im working on I ran into a very strange error when trying to load in a simple .jpg image. The image wouldn’t load. Now this sounds like a very familiar issue and easily solvable right? That what I thought too, but as it turns out, it turned into a couple hours of work and debugging. The issue wasn’t as simple as an incorrect url, network timeouts, dead links, etc… Debugging the complete() event shows the image was getting to where it had to get to and that flex felt that it did everything it had to do. So what was the problem with loading the image?

Flex can load .jpg, .png, .gif and so on… so why isnt the .jpg that was provided to me via the middle tier service loading in? Well it turns out that this wasn’t any ordinary jpeg, infact, it wasnt a jpeg at all. After a couple of hours of looking at everything under the sun, I finally looked into the image itself. I opened the image in HexEdit and I noticed this .jpg file had a header of “BM”… thats a Bitmap not a jpeg. Try it out, open any jpeg you have in HexEdit or some kind of binary reader and notice the headers should read “JFIF” not “BM…”. Apparently the team responsible for submitting images to the content delivery system had saved a bitmap as a jpg by simply editing the file extension from .bmp to .jpg which im sure may have seemed harmless but in fact there is a so much more to it when you convert from one file format to another.

At the end of the day, it wasnt the worlds biggest issue but it did cause a delay and I figured maybe this could help anyone going through the same issue. Since then when I see image load I/O errors now I do the following to manage the issue

There's 0 Comment So Far

Share your thoughts, leave a comment!