Friday, August 9, 2013

Google Ignores Image Extensions


Google Plays Image Extensions


Google! It's a PNG, not a JPG


Google Plus Summarizes Backed-Up Videos as Animated GIF

I noticed the other day while working on my Photo Feed Display project that PNG files in my Picasa Web Albums RSS Feed were not being processed correctly. I had JUST added PNG support, so I thought the error was probably in my code. As I dug deeper, I noticed that the images referenced in the RSS Feed had .jpg extensions, not .png extension. I thought this was probably intentional since .jpg (for photo) often provide better results for a given file size. I thought that Google was doing me a favor, making .jpg thumbnails of my .png files for ease of use. I'll take it. But, I was mistaken. Even though the RSS Feed explicitely listed the media with a .jpg extention, they were still PNG files.

Here's what I've found -- Google ignores image extensions. Presumably, they do this because web browsers also ignore image extensions (for widely supported image formats)*. For example, my Picasa Web Album RSS Feed lists the following image source:

But wait! I get the same image in my browser if I remove the file at all:

Or, I can see a larger variant by removing the last bit: must default to the original size or a larger variant or something.

It is Still a PNG

This is all good and dandy, but, while not stated (or incorrectly stated), the file is still a PNG. My Photo Feed Display generates thumbs of photos using a PHP function imagecreatefromjpeg() and fails when referencing any of the links above as the source image. Further, it works when I use the (similar) function, imagecreatefrompng().

Why This Matters

If you are just viewing files in a browser, it shouldn't (since the extensions are ignored -- see my proof below, by the asterisk -- by web browsers). If you are processing the files, it very well may.

I Thought this post Concerned GIF files, Too...

Oh yeah! It does. A week after discovering the previous information, I was viewing my Google Automatic Backup files on Google Plus and noticed it had converted a video into (what I assumed was) an animated GIF file. Awesome! I love those. This time, when I right-clicked to copy the image URL, I noticed that it didn't have an extension. I thought it may be some fancy code that uses multiple JPG files, changing the displayed JPG a few times per second using javascript, which would be fine but wouldn't allow me to link to a summary of the video as an animated GIF would. Nope, true animated GIF file, despite the lack of extension. The same logic as above, as far as a scaled down version, applies. For example:

...shows a animated GIF summarizing the video clip. Similarly, but somewhat less intuitively, removing the "=w369-h207-p-no" (width, height, progressive[?], interlaced[?]) shows a larger version:

Lastly, when I 'inspect element' for a (presumed) animated GIF on my Google Plus page, I get the following source image:

...but, it is clearly not a .m4v (even though it probably links to one). When I remove the last part, I still get the animated GIF (this time, with 'play' overlay):

Or, I can take more off the end to get a larger version:

In Conclusion

Hope this helps someone!



* I haven't researched this, but I'm pretty sure it is true.

No comments: