Skip to content

Instantly share code, notes, and snippets.

@abelaska
Last active August 12, 2020 05:50
Show Gist options
  • Save abelaska/ab376d4cf08806cf942ffc2d0cee2628 to your computer and use it in GitHub Desktop.
Save abelaska/ab376d4cf08806cf942ffc2d0cee2628 to your computer and use it in GitHub Desktop.
Google’s authentication-less on-the-fly image resizing service

Google's authentication-less on-the-fly image resizing service

I found it while poking around the Google+ HTML. Jotting down some notes felt like a good idea, so here goes. If you know more about this API, let me know, please!

(Word of warning: I spent ~30 minutes on both my experimentation and this here write-up, so it might not be the most thought-provoking, brilliant thing you read today.)

Base URL

https://images1-focus-opensocial.googleusercontent.com/gadgets/proxy

Parameters:

  • url: original image URL
  • container: must be "focus" (i dunno lol)
  • refresh: time (in seconds) to cache it on G's servers
  • resize_w: width in pixels
  • resize_h: height in pixels, resize_h=0 without resize_w means no resize
  • no_expand=1: when scaled to a larger size than the image itself is, it will not be resized (e.g. the dimensions set with resize_* act as a maximum but are not forced on smaller images).
  • no_expand=0: seems to function as something like "force resize"
  • rewriteMime=image/*: normally the mime type is something like image/png; charset=UTF-8. With this option you can overwrite it. The * functions as a placeholder for whatever mime the image originally had, i. e. rewriteMime=image/* would give image/png if used on a PNG. Note that it won't affect the proxying – you'll still receive the same with or without this option (only the mime type changes)
  • imgmax: ?

You can either specify both resize_* parameters or just one.

Examples

Let's resize that big panorama picture I took in Istanbul last year.

Make it square, 300x300px:

https://images1-focus-opensocial.googleusercontent.com/gadgets/proxy?url=https%3A%2F%2Fdl.dropboxusercontent.com%2Fu%2F7298%2Fblog%2FBlick_von_der_S%25C3%25BCleymaniye-Moschee.jpg&container=focus&resize_w=300&resize_h=300

Make it 750px wide and keep the aspect ration:

https://images1-focus-opensocial.googleusercontent.com/gadgets/proxy?url=https%3A%2F%2Fdl.dropboxusercontent.com%2Fu%2F7298%2Fblog%2FBlick_von_der_S%25C3%25BCleymaniye-Moschee.jpg&container=focus&resize_w=750

Quirks

At least in Chrome, opening the URL in the browser will force a download of a text file (which is actually a JPG). Putting the URL in an <img> tag is fine. Or just use curl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment