Image Optimization

Image Optimization

Optimize images on the IPFS gateway

The AIOZ Pin gateway optimizes IPFS images at request time using URL parameters to reduce bytes and improve Core Web Vitals. Currently, we support optimization for the formats BMP, GIF, JPG, PNG, and WebP. Here is how you can use those options:

GEThttps://{gateway}.aiozpin.network/ipfs/{cid}

Parameters

gateway* set to public or premium
cid* the image CID on IPFS

Query

img-width The width to resize the image, 0 means original width (default 0)
img-height The height to resize the image, 0 means original height (default 0)
img-fit The fit mode to resize the image, valid values: scale-down, contain, cover, crop, pad (default scale-down). Note: padding is applied. If you only need letterboxing, prefer img-fit=contain and handle boxing with CSS (e.g., object-fit: contain).
img-gravity When cropping with "fit=cover", specifies the most important side or point in the image that shouldn't be cropped. Choose a side: auto, left, right, top, bottom or a point XxY on a 0-1 scale (e.g. 0x1 means left and bottom, 0.5x0.5 means center, 0.5x0.33 means a point in the top third of the image)
img-quality The quality of the image (0-100), used only for JPG and WEBP (default 80)
img-dpr Device Pixel Ratio, a multiplier for width and height that makes it easier to request higher-DPI sizes (default 1).)
img-sharpen The strength of the sharpen filter, is a float from 0 to 10 (default 0)
img-anim Whether to preserve animation of GIF images (default false)
img-metadata Controls amount of invisible metadata (EXIF data) that should be preserved. "keep" preserves most of the image metadata, "copyright" discards all but the copyright tag and "none" discards all invisible metadata
img-onerror Set img-onerror=redirect to fall back to the original source URL on fatal optimization errors.

Response

200: OK
The optimized image
curl --location --request GET 'https://public.aiozpin.network/ipfs/{cid}?img-width=320&img-height=320&img-fit=contain&img-quality=80'