The Images Go API provides the ability to serve images directly from Blobstore, and to optionally resize or crop those images on the fly.
The service accepts image data in the JPEG, PNG, WEBP, GIF (including animated GIF), BMP, TIFF and ICO formats.
It can return transformed images in the JPEG, WEBP and PNG formats. If the input format and the output format are different, the service converts the input data to the output format before performing the transformation.
Serving and re-sizing images from the Blobstore
image.ServingURL function allows you to generate a stable, dedicated URL for serving web-suitable image thumbnails. You simply store a single copy of your original image in Blobstore, and then request a high-performance per-image URL. This special URL can serve that image resized and/or cropped automatically, and serving from this URL does not incur any CPU or dynamic serving load on your application (though bandwidth is still charged as usual). Images are served with low latency from a highly optimized, cookieless infrastructure.
The URL returned by the function is always public, but not guessable; private URLs are not currently supported. If you wish to stop serving the URL, delete it using the
If you pass an
image.ServingURLOptions value to the function, it returns a URL encoded with those options. If you pass
nil, the function returns the default URL for the image, for example:
You can resize and crop the image dynamically by specifying the arguments in the URL. The available arguments are:
xxis an integer from 0–1600 representing the length, in pixels, of the image's longest side. For example, adding
=s32resizes the image so its longest dimension is 32 pixels.
=sxx-cwhere xx is an integer from 0–1600 representing the cropped image size in pixels, and
-ctells the system to crop the image.
# Resize the image to 32 pixels (aspect-ratio preserved) http://lhx.ggpht.com/randomStringImageId=s32 # Crop the image to 32 pixels http://lhx.ggpht.com/randomStringImageId=s32-c
A note about deletion
Whether you store your images in Blobstore or Google Cloud Storage, the right way to stop an image from being publicly accessible through the serving URL is to call the
If you merely delete the underlying stored image from Blobstore , under some circumstances the image may remain accessible through the serving URL.