View source on GitHub |
Obtains a URL that will serve the underlying image.
google.appengine.api.images.get_serving_url(
blob_key, size=None, crop=False, secure_url=None, filename=None, rpc=None
)
This URL is served by a high-performance dynamic image serving infrastructure. This URL format also allows dynamic resizing and cropping with certain restrictions. To dynamically resize and crop, specify size and crop arguments, or simply append options to the end of the default URL obtained via this call.
Example::
get_serving_url -> "http://lh3.ggpht.com/SomeCharactersGoesHere"
To get a 32-pixel-sized version (aspect-ratio preserved), append =s32
to the
URL::
http://lh3.ggpht.com/SomeCharactersGoesHere=s32
To get a 32-pixel cropped version, append =s32-c
::
http://lh3.ggpht.com/SomeCharactersGoesHere=s32-c
Available sizes are any integer in the range [0, 1600] and is available as
IMG_SERVING_SIZES_LIMIT
.
Args | |
---|---|
blob_key
|
The BlobKey , BlobInfo , string, or Unicode representation of
BlobKey of the blob whose URL you require.
|
size
|
Integer of the size of resulting images. |
crop
|
Boolean value. True requests a cropped image, while False requests
a resized image.
|
secure_url
|
Boolean value. True requests a https URL, while False
requests a http URL.
|
filename
|
The file name of a Google Storage object whose URL you require. |
rpc
|
Optional UserRPC object. |
Returns | |
---|---|
A URL string. |
Raises | |
---|---|
BlobKeyRequiredError
|
If a blob key was not specified in the constructor. |
UnsupportedSizeError
|
If you specified an invalid size parameter. |
BadRequestError
|
If crop and size are present in the wrong
combination, or if blob_key and filename are both specified.
|
TypeError
|
If secure_url is not a boolean type.
|
AccessDeniedError
|
If blob_key refers to a Google Storage object and
the application does not have permission to access the object.
|
ObjectNotFoundError
|
If blob_key refers to an object that doesn't
exist.
|