Showing posts with label jpeg. Show all posts
Showing posts with label jpeg. Show all posts

Friday, August 9, 2013

Google Ignores Image Extensions

Or

Google Plays Image Extensions

Or

Google! It's a PNG, not a JPG

Or

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:

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOVLZF7VkKst4rpB4E-NlcNHicnRIccdr4JPCUZFJbAITNU6BZbW9XnfQ4n_kY6RzGVuW7i_loHu0dNKZ_jpfa0Re51RxFrgohXcZ3n6wK6zxgBv_ixQeAwaZNlQNxUGixaTRpUFVqCsN8/s288/tourniquet%252520news%252520page.jpg

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

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOVLZF7VkKst4rpB4E-NlcNHicnRIccdr4JPCUZFJbAITNU6BZbW9XnfQ4n_kY6RzGVuW7i_loHu0dNKZ_jpfa0Re51RxFrgohXcZ3n6wK6zxgBv_ixQeAwaZNlQNxUGixaTRpUFVqCsN8/s288/

Or, I can see a larger variant by removing the last bit:

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOVLZF7VkKst4rpB4E-NlcNHicnRIccdr4JPCUZFJbAITNU6BZbW9XnfQ4n_kY6RzGVuW7i_loHu0dNKZ_jpfa0Re51RxFrgohXcZ3n6wK6zxgBv_ixQeAwaZNlQNxUGixaTRpUFVqCsN8/

...it 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:

https://lh3.googleusercontent.com/krJiBTc-61AznapjS1u4nON7BC6crcwtStAHTYYE7_8=w369-h207-p-no

...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:

https://lh3.googleusercontent.com/krJiBTc-61AznapjS1u4nON7BC6crcwtStAHTYYE7_8

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

https://lh4.googleusercontent.com/-xS4TzDbCnIU/UgPbWW5PUpI/AAAAAAAAEcE/iUV1gyNyJlY/s122-c/VID_20130806_174425.m4v

...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):

https://lh4.googleusercontent.com/-xS4TzDbCnIU/UgPbWW5PUpI/AAAAAAAAEcE/iUV1gyNyJlY/s122-c/

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

https://lh4.googleusercontent.com/-xS4TzDbCnIU/UgPbWW5PUpI/AAAAAAAAEcE/iUV1gyNyJlY/

In Conclusion

Hope this helps someone!

-

References

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