Metadata and Exif
Metadata Endpoint
imagor provides a metadata endpoint that extracts information such as image format, resolution and Exif metadata. Under the hood, it tries to retrieve data just enough to extract the header, without reading and processing the whole image in memory.
To use the metadata endpoint, add /meta right after the URL signature hash before the image operations. Example:
http://localhost:8000/unsafe/meta/fit-in/50x50/raw.githubusercontent.com/cshum/imagor/master/testdata/Canon_40D.jpg
{
"format": "jpeg",
"content_type": "image/jpeg",
"width": 50,
"height": 34,
"orientation": 1,
"pages": 1,
"bands": 3,
"exif": {
"ApertureValue": "368640/65536",
"ColorSpace": 1,
"ComponentsConfiguration": "Y Cb Cr -",
"Compression": 6,
"DateTime": "2008:07:31 10:38:11",
"ISOSpeedRatings": 100,
"Make": "Canon",
"MeteringMode": 5,
"Model": "Canon EOS 40D",
//...
}
}
Params Endpoint
Prepending /params to the existing endpoint returns the endpoint attributes in JSON form, useful for previewing the endpoint parameters. Example:
curl 'http://localhost:8000/params/g5bMqZvxaQK65qFPaP1qlJOTuLM=/fit-in/500x400/0x20/filters:fill(white)/raw.githubusercontent.com/cshum/imagor/master/testdata/gopher.png'
Metadata Filters
These filters add computed values to the metadata response. They require the full image to be downloaded and decoded.
blurhash(x,y)
Computes a BlurHash string for the image. x and y are the horizontal and vertical component counts (between 1 and 9). Higher values produce more detail at the cost of a longer hash string.
http://localhost:8000/unsafe/meta/filters:blurhash(4,3)/raw.githubusercontent.com/cshum/imagor/master/testdata/gopher.png
{
// ...
"blurhash": "LGF5]+Yk^6#M@-5c,1J5@[or[Q6."
}
thumbhash()
Computes a ThumbHash string for the image, returned as a base64-encoded string. ThumbHash produces better color reproduction and supports transparency, and requires no configuration parameters.
http://localhost:8000/unsafe/meta/filters:thumbhash()/raw.githubusercontent.com/cshum/imagor/master/testdata/gopher.png
{
// ...
"thumbhash": "3OcRJYB4d3h/iIeHeEh3eIhw+j3A"
}
avgcolor()
Computes the average color of the image as an average_color object with r, g, and b integer fields (0–255).
For images with an alpha channel, transparent pixels will be filled with black. If you'd like to control the fill color, you can use avgcolor() in conjunction with the background_color() filter.
http://localhost:8000/unsafe/meta/filters:avgcolor()/raw.githubusercontent.com/cshum/imagor/master/testdata/gopher.png
{
// ...
"average_color": { "r": 99, "g": 172, "b": 229 }
}