Back

Blog details

How to Resize Images Using URL Parameters on AIOZ Pin

AIOZ Network
9 min readAugust 19, 2026
aioz-pindeveloper
AIOZ Pin cover image with the headline Resize Images on AIOZ Pin Using URL Parameters

To resize images using URL parameters on AIOZ Pin, add img- query parameters to the gateway link that already serves your pinned image. For example, ?img-width=400&img-fit=cover returns a 400-pixel version. You don't upload a copy, call an API, or send an API key.

TL;DR:

  • Any image pinned on AIOZ Pin can be resized, cropped, compressed, or served as WebP by changing its gateway URL.
  • There are 11 documented parameters, from img-width and img-fit to img-format=webp and img-onerror=redirect. At least one must be set.
  • Supported formats are BMP, GIF, JPG/JPEG, PNG, and WebP. The public gateway needs no authentication for this.
  • The payment page lists no separate fee for transforms. You pay storage and bandwidth as usual.

Updated Oct 19, 2026: added the img-format=webp option and corrected defaults (img-metadata is copyright, img-gravity is center, img-dpr tops out at 3). Also new: a fit-mode diagram, a way to measure the savings, the SDK's optimizeImage, and use cases from our image optimization overview. Updated Oct 29, 2026: merged our separate post Image Optimization on AIOZ Pin: Smarter Image Delivery from IPFS into this guide, adding a presets rollout section and two FAQs.

How do you resize an image with URL parameters?

Every file you pin is reachable at https://<gateway>.aiozpin.network/ipfs/<CID>, where the gateway is public or your own premium subdomain. Add query parameters to that URL and the gateway returns a transformed image, built at request time. The original stays pinned once, unchanged. This is the example from the AIOZ Pin image optimization docs:

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

That URL asks for an image no wider than 300 pixels and no taller than 600, cropped to fill the box. Request the same CID with no parameters and you get the original file. The docs say at least one option must be set for optimization to run.

This matters because an original photo is often far larger than the slot it fills. A 4,000-pixel camera shot shown in a 400-pixel card wastes most of its bytes. Sending each placement the size it needs cuts transfer, which speeds up pages and lowers your bandwidth bill.

What does each img- parameter do?

The gateway docs list 11 options. Defaults below come from the gateway docs. The img-anim default comes from the API reference, since the gateway page doesn't give one.

ParameterWhat it doesDefault
img-widthMaximum width in pixels. Exact effect depends on img-fit. If you set only the height, the width defaults to it.0 (source)
img-heightMaximum height in pixels. If you set only the width, the height defaults to it.0 (source)
img-fitHow width and height are applied: scale-down, contain, cover, crop, or padscale-down
img-gravityFocal point for cover: auto, top, bottom, left, right, or XxY from 0.0 to 1.0center
img-qualityQuality for JPEG and WebP, 1 to 100. The docs suggest 50 for small files and 90 for high quality.80
img-formatSet to webp to serve WebP to browsers that support itsource format
img-dprDevice pixel ratio, 1 to 3. Multiplies width and height for high-density screens.1
img-sharpenSharpening strength, 0 to 100
img-animtrue or false: whether animated images such as GIFs stay animated or become stillsfalse (API reference)
img-metadataEXIF handling: keep (including GPS), copyright, or nonecopyright
img-onerrorSet to redirect to serve the original image if optimization failsoff

Two details trip people up. img-quality only affects JPEG and WebP, so it does nothing to a PNG unless you also convert with img-format=webp. And img-metadata defaults to copyright, which strips GPS and camera data but keeps copyright fields. Use keep only if you want location data public.

Which img-fit mode should you use?

img-fit decides what happens when your box doesn't match the photo's shape. All five modes keep the aspect ratio. The diagram shows what each one does with a 1600 x 900 photo and a 600 x 600 request.

Illustration of img-fit modes for a 1600 by 900 photo requested at 600 by 600: scale-down and contain return 600 by 338, cover and crop return a cropped 600 by 600 square, pad returns 600 by 600 with white bands
  • scale-down (the default) shrinks the image to fit but never enlarges it. It's the safe choice for general resizing.
  • contain scales up or down to fit inside the box. Use it for logos and anything that must not be cropped.
  • cover fills the box and may crop. Use it for hero banners and fixed-shape cards, and set img-gravity to keep the subject.
  • crop acts like scale-down for small images and like cover for large ones. It suits thumbnail grids with mixed source sizes.
  • pad fits the image and fills the rest, usually with white. For a transparent look, the docs suggest CSS object-fit: contain instead.

With cover, img-gravity=auto picks the main focus area for you. Use top, left, and so on, or a coordinate such as 0.5x0.2, when you know where the subject sits.

Building a responsive image set

Because the transform is only a query string, a standard srcset works with no build step. One pinned file and one CID give you three delivered sizes, and the browser picks the one that fits:

<img
  src="https://<gateway>.aiozpin.network/ipfs/<CID>?img-width=800&img-format=webp"
  srcset="
    https://<gateway>.aiozpin.network/ipfs/<CID>?img-width=400&img-format=webp 400w,
    https://<gateway>.aiozpin.network/ipfs/<CID>?img-width=800&img-format=webp 800w,
    https://<gateway>.aiozpin.network/ipfs/<CID>?img-width=1200&img-format=webp 1200w
  "
  sizes="(max-width: 600px) 400px, 800px"
  alt="Product photo"
/>

For a single fixed-size image on high-density screens, ?img-width=400&img-dpr=2 does the job with less markup. It serves an 800-pixel image that you display at 400 CSS pixels.

Rolling out presets instead of pre-resized copies

The older way to handle image sizes is to render every size at build time and pin each one. It works, but it fixes your sizes in advance, so a new layout means another render, another upload, and a new set of CIDs to swap into your pages.

With gateway parameters, you pin one original and describe each size in its URL. The difference also shows up in your pinned-file count. Keeping an original plus three rendered sizes for 10,000 product photos is 40,000 pinned files, which uses the entire free allowance on the payment page. One original per photo keeps you at 10,000, and you store one file per photo instead of four.

Most sites only need a handful of sizes. Here's a starting set you can adapt, built only from documented parameters. The avatar preset asks for 96 pixels at img-dpr=2, so the gateway serves 192 pixels for sharp display on high-density screens:

PresetQuery stringWhere you'd use it
Card?img-width=400&img-height=300&img-fit=cover&img-quality=80Product grids and NFT gallery tiles
Hero?img-width=1600&img-format=webpFull-width banners
Avatar?img-width=96&img-height=96&img-fit=cover&img-gravity=auto&img-dpr=2Profile pictures on high-density screens
Share card?img-width=1200&img-height=630&img-fit=coverLink previews

To roll the presets out across a site, work through these steps in order:

  1. Pin the highest-quality original you have. The default scale-down mode never enlarges an image, so the source file sets the ceiling for every preset.
  2. Keep the preset query strings in one config file, so every page and template builds the same URLs.
  3. Test each preset on a few real images, including a PNG and an animated GIF, because those two behave differently from JPEG.
  4. Replace the original image links in your CMS, docs, or frontend with the preset URLs.
  5. Measure the bytes before and after on the same CIDs, as the next section shows.

Measuring the savings on your own images

We don't publish before-and-after numbers here, because savings depend on your source files. You can measure them in two requests. Compare the byte count of the original with a resized copy of the same CID (commands from the documented URL format, not run here):

# Original bytes
curl -s -o original -w '%{size_download} bytes\n' "https://public.aiozpin.network/ipfs/<CID>"

# Same CID at 400 px wide, quality 50, WebP for browsers that accept it
curl -s -o small -H 'Accept: image/webp' -w '%{size_download} bytes\n' \
  "https://public.aiozpin.network/ipfs/<CID>?img-width=400&img-quality=50&img-format=webp"

Run it on a few typical images, a large photo, a PNG screenshot, and a GIF, to see where transforms pay off. Keep the public gateway's limits in mind while testing: 15 requests per minute per CID and 200 per minute per IP.

Handling errors without a broken image icon

img-onerror=redirect tells the gateway to send the original file if optimization fails, instead of an error. On a production <img> tag, that's the difference between a broken-image icon and a full-size image that still loads. Set it on anything user-facing where an odd source file could otherwise break your layout.

Where gateway resizing helps most

  • NFT galleries: small thumbnails in the grid, the full image on the detail page, all from one CID.
  • Product grids: cover plus img-gravity gives every card the same shape, whatever the source.
  • Docs and blogs: screenshots served at reading width instead of full monitor size.
  • Share previews: a fixed 1200 x 630 crop for link cards, without a second upload.

It isn't a full image pipeline. The docs list no SVG support, no video thumbnails, and no subject detection beyond img-gravity=auto. For those, you still need a separate service.

How AIOZ Pin handles image resizing

Resizing runs on our gateways, for content pinned on AIOZ Pin. The public gateway needs no authentication, so URLs drop straight into HTML or CSS, which can't send headers. It's meant for testing, though. For production traffic, a premium gateway has no predefined rate limit and serves from 200+ edge caching locations. Free plan users get a limited premium gateway that serves single files such as images, which covers this use.

From Node.js, the SDK wraps the same options in optimizeImage and returns the image bytes. This is the README example for version 1.0.1, lightly trimmed (not run here):

import { writeFileSync } from 'fs'

const result = await client.optimizeImage({
  cid: 'YOUR CID',
  gatewayProviderUrl: 'GATEWAY URL',
  config: { imgWidth: 800, imgQuality: 75, imgFit: 'cover', imgGravity: '0.5x0.5' },
  axiosConfig: { responseType: 'arraybuffer' }
})
writeFileSync('optimized-image.jpg', Buffer.from(result))

There's no separate line item for transforms on the payment page. Storage is $20 per TB per month and bandwidth $20 per TB, so a smaller image also costs you less to serve.

Next step: read the AIOZ Pin image optimization docs and try a parameter on one of your pinned images.

Frequently Asked Questions

How do I resize an image using URL parameters on AIOZ Pin? Add img-width, img-height, and optionally img-fit to the gateway URL, for example https://public.aiozpin.network/ipfs/<CID>?img-width=400.

Do I need an API key to resize images? No. The docs say public gateway image optimization needs no authentication, so the URL works directly in an <img> tag.

Which image formats are supported? BMP, GIF, JPG/JPEG, PNG, and WebP. There's no SVG support in the list.

Can AIOZ Pin convert images to WebP? Yes. Add img-format=webp and the gateway serves WebP to browsers that support it, falling back to standard formats otherwise.

Does resizing cost extra? The payment page lists storage, bandwidth, and pinned-file fees, with no separate charge for transforms. Resized images are served as normal gateway bandwidth.

What happens if a transform fails? By default you get an error. Add img-onerror=redirect and the gateway serves the original image instead.

Do I need to pin a separate copy of an image for each size? No. You pin one original, and each URL with different img- parameters returns a different size from it. Extra pre-rendered copies only add pinned files and storage to your bill.

Will a resized GIF stay animated? The API reference says img-anim controls whether GIF animation is preserved and defaults to false, so add img-anim=true when you want the animation kept. The gateway page describes the same option as turning animations into stills, so test one GIF before you rely on either reading.

References

We only send updates when meaningful changes ship, and you can unsubscribe anytime

Related Content

blog thumbnail

What Is a Multiaddr? Peer IDs and Addresses in IPFS

A multiaddr is a network address that names every protocol it uses, like /ip4/.../tcp/4001/p2p/ and a peer ID. Learn to read one and how IPFS peer IDs work.

7 min readNovember 06, 2026
blog thumbnail

IPFS Bootstrap Nodes and How a New Node Finds Its Peers

IPFS bootstrap nodes are the first peers a new node dials to join the Amino DHT. See how Kubo uses them, who runs them after Shipyard, and how to edit the list.

6 min readNovember 04, 2026
blog thumbnail

ipfs.io Gateway Not Working? What Changed and Who Runs It

The ipfs.io gateway now returns HTTP 429 to scripts and servers and sends browsers to inbrowser.link. See who runs the public IPFS services and what to change.

6 min readNovember 02, 2026
blog thumbnail

IPFS Glossary: Key IPFS and libp2p Terms Explained A to Z

An IPFS glossary of 115 terms from A to Z: CIDs, Bitswap, the DHT, IPNS, gateways and pinning, each defined in plain words and linked to a deeper guide.

21 min readOctober 31, 2026
blog thumbnail

What Is IPFS Provide Sweep? How Kubo Announces Many CIDs

IPFS Provide Sweep is Kubo's provider that batches CIDs by DHT region, not one lookup each. See how it works, when it became default, and how to check it.

6 min readOctober 30, 2026
blog thumbnail

IPFS Dedicated Gateway Free vs Paid Plans on AIOZ Pin

An IPFS dedicated gateway on AIOZ Pin is called a premium gateway. See what the free plan limits, what a paid plan adds, and what happens at zero balance.

6 min readOctober 28, 2026