Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of all the App Engine images service get_serving_url() URI options

In response to another question, a commenter mentioned an undocumented URI option I was not aware of to flip images horizontally/vertically with the App Engine images service.

The documentation mentions a few basic options:

  • =s0 — fullsize
  • =s640 — longest edge 640px long
  • =s640-c — 640px square

Would be nice to generate a comprehensive list of options, or if someone could provide any more options they know about here to serve as de facto documentation.

like image 862
Taylor Hughes Avatar asked Aug 05 '14 21:08

Taylor Hughes


1 Answers

Between reading some random posts and manually doing some investigative research, I have put together the following list. Please drop any other knowledge in other answers or in comments and I can integrate it here.

Usage Example

We can effect various image transformations by tacking strings onto the end of an App Engine blob-based image URL, following an = character. Options can be combined by separating them with hyphens, eg.:

http://[image-url]=s200-fh-p-b10-c0xFFFF0000 

or:

http://[image-url]=s200-r90-cc-c0xFF00FF00-fSoften=1,20,0: 

... which have the following effect (documentation below):

As an example of how awesome this is, here's an animated GIF, downsized and inverted:

… which we can then convert into an MP4 video with one extra parameter: click to see MP4 version


SIZE / CROP

  • s640 — generates image 640 pixels on largest dimension
  • s0 — original size image
  • w100 — generates image 100 pixels wide
  • h100 — generates image 100 pixels tall
  • s (without a value) — stretches image to fit dimensions
  • c — crops image to provided dimensions
  • n — same as c, but crops from the center
  • p — smart square crop, attempts cropping to faces
  • pp — alternate smart square crop, does not cut off faces (?)
  • cc — generates a circularly cropped image
  • ci — square crop to smallest of: width, height, or specified =s parameter
  • nu — no-upscaling. Disables resizing an image to larger than its original resolution.

PAN AND ZOOM

  • x, y, z: — pan and zoom a tiled image. These have no effect on an untiled image or without an authorization parameter of some form (see googleartproject.com).

ROTATION

  • fv — flip vertically
  • fh — flip horizontally
  • r{90, 180, 270} — rotates image 90, 180, or 270 degrees clockwise

IMAGE FORMAT

  • rj — forces the resulting image to be JPG
  • rp — forces the resulting image to be PNG
  • rw — forces the resulting image to be WebP
  • rg — forces the resulting image to be GIF

  • v{0,1,2,3} — sets image to a different format option (works with JPG and WebP)

Forcing PNG, WebP and GIF outputs can work in combination with circular crops for a transparent background. Forcing JPG can be combined with border color to fill in backgrounds in transparent images.

ANIMATED GIFs

  • rh — generates an MP4 from the input image
  • k — kill animation (generates static image)

MISC.

  • b10 — add a 10px border to image
  • c0xAARRGGBB — set border color, eg. =c0xffff0000 for red
  • d — adds header to cause browser download
  • e7 — set cache-control max-age header on response to 7 days
  • l100 — sets JPEG quality to 100% (1-100)
  • h — responds with an HTML page containing the image
  • g — responds with XML used by Google's pan/zoom

Filters

  • fSoften=1,100,0: - where 100 can go from 0 to 100 to blur the image
  • fVignette=1,100,1.4,0,000000 where 100 controls the size of the gradient and 000000 is RRGGBB of the color of the border shadow
  • fInvert=0,1 inverts the image regardless of the value provided
  • fbw=0,1 makes the image black and white regardless of the value provided

Unknown Parameters

These parameters have been seen in use, but their effect is unknown: no, nd, mv

Caveats

Some options (like =l for JPEG quality) do not seem to generate new images. If you change another option (size, etc.) and change the l value, the quality change should be visible. Some options also don't work well together. This is all undocumented by Google, probably with good reason.

Moreover, it's probably not a good idea to depend on any of these options existing forever. Google could remove most of them without notice at any time.

like image 54
Taylor Hughes Avatar answered Nov 01 '22 19:11

Taylor Hughes