Gateway
Image Optimizations

Image Optimizations

Optimize images on the IPFS gateway

Our IPFS gateway provides a list of options that you can use to optimize images stored on the IPFS network. Currently, we support optimization for the formats bmp, gif, jpg, jpeg, png and webp. These options can significantly improve load time and experience when viewing image content.

Usage

To use image optimizations on images that you've uploaded, simply add the queries mentioned in the reference via query parameters. Your full url might look something like this:

https://premium.aiozpin.network/ipfs/bafkreiefnp4dflv35vsqzrnp25woubdbylgesttpanq6dfkctbhgo3lvy4?img-width=300&img-height=600&img-fit=cover

Reference

At least one option must be specified for the optimization feature to activate.


img-width unsigned integer

Specifies the maximum width in pixels of the image (range 1 to None). Exact effect depends on the selected img-fit.

Default: 0 (Source). If omitted but img-height is set, defaults to img-height.


img-height unsigned integer

Specifies the maximum height in pixels of the image (range 1 to None). Exact effect depends on the selected img-fit.

Default: 0 (Source). If omitted but img-width is set, defaults to img-width.


img-dpr unsigned integer

Specifies the Device Pixel Ratio. This multiplies the width and height to support high-DPI displays (range 1 to 3).

Default: 1.


img-fit string

Affects interpretation of width and height. All resizing modes attempts to preserve aspect ratio.

Default: scale-down. Available fit modes:

  • img-fit=scale-down Shrinks the image to fit, but doesn't enlarge it.
  • img-fit=contain Scales the image up or down to fit within the dimensions.
  • img-fit=cover Fills the dimensions completely; may crop the image.
  • img-fit=crop Shrinks and crops as needed to fit; behaves like scale-down for small images and cover for larger ones.
  • img-fit=pad Fits the image within dimensions with padding (usually white); use CSS object-fit: contain for transparent backgrounds.

img-gravity string

Defines the focal point when cropping with img-fit=cover.

Default: center. Available values:

  • img-gravity=auto Automatically detects the main focus area.
  • img-gravity=side Can be top, bottom, left or right
  • img-gravity=XxY Coordinates between 0.0 and 1.0; e.g., 0.5x0.5 is center, 0x1 is bottom-left

img-quality unsigned integer

Sets the image quality for JPEG and WebP formats (range 1-100).

Default: 80. Recommended values: 50 (small files), 90 (high quality).


img-format string

If value is webp then allows serving Webp image for compatible browsers. Falls back to standard formats if unspecified.


img-anim string

Converts animated images (like GIFs) to still images to reduce file size and prevent flashing effects. Accepted values include true and false.


img-sharpen unsigned integer

Specifies the strength of the sharpening filter. Default: 0 (no sharpening). Accepted values range from 0-10.


img-onerror string

Determines behavior on fatal errors when optimizing image. Specify img-onerror=redirect to redirect to original image URL.


img-metadata string

Controls how much invisible metadata (EXIF) is retained

Default: copyright. Available values:

  • img-metadata=keep Retains all metadata if possible, including GPS.
  • img-metadata=copyright Keeps only copyright information.
  • img-metadata=none Strips all metadata.