How it works
- You link images through snappyimg, specifying desired resolution, resize mode, etc.
- The first time someone loads the asset, snappyimg downloads your original image and processes it.
- All further requests for the image are served from cache.
Implementation details
Instead of linking your image directly such as <img src="$imageUrl">
,
you use a signed URL that looks roughly like this:
https://serve.snappyimg/…/$imageUrl…
.
You may assemble the URL on your servers manually, but there are multiple implementations available what will greatly simplify the process.
Ⓐ Building the URL with a library
Ⓑ Building the URL manually
https://$stage.snappyimg.com/$appToken/$signature/base64($imageUrl).$format /
$stage |
Either demo or serve . Demo is available is Free plan, but places a watemark on all images. Should only be used for development and testing. Production value is serve and is only available in Paid subscription. |
---|---|
$appToken |
Value we generate for you when you register. |
$signature |
The signature is a base64 encoded output of a SHA256 HMAC. It prevents 3rd parties from using your paid account maliciously.
You compute this value based on the remaining parameters. The formula is:
Where |
|
Configuration for the final image in the following format:
$resize/$width/$height/$gravity/$enlarge
Allowed values are explained below.
|
$resize |
Allowed values are
|
$width ,$height |
Maximum dimensions in pixels the resulting image should have. Based on the combinations of $resize and $enlarge , the actual dimensions may be smaller.
|
$gravity |
Tells snappyimg how to position an image in canvas when a part of the image (if any) should be cropped.
Allowed values are
sm detect interesting areas automatically,
ce center,
no top edge,
so bottom edge,
ea right edge and
we left edge.
|
$enlarge |
Whether original image should be scaled-up to given $width×$height if it is
smaller. Value of 1 allows scaling-up, 0 disables it.
|
$format |
One of png , jpg or webp . If the original image is in different format,
it is converted. Transparency is supported.
|
Guarantees
Our processing servers have an overall uptime of 99.950%. Furthermore, once an image is processed, all requests are handled exclusively by Cloudflare edge servers.
On the first request most images are processed in under 800 milliseconds. Subsequent requests are served from cache in under 50 milliseconds.
Limitations
- Maximum width and height: 16384 pixels
- Maximum resolution: 50 megapixels