Prompt

How do I generate AVIF and WebP versions of images?

Technology / CDN & Edge Infrastructure1 observationLast seen Nov 2, 2026

Latest observation

Nov 2, 2026OpenAI APIWeb search: off

You can generate AVIF and WebP versions of images using either command-line tools or libraries in your app/build pipeline.

1) Using ImageMagick + compatible encoders

If your ImageMagick build supports them:

magick input.jpg output.webp
magick input.jpg output.avif

If AVIF/WebP support isn’t available, you may need extra libraries installed (libwebp, libavif, etc.).

2) Using ffmpeg for single images

For still images, ffmpeg can convert formats:

ffmpeg -i input.jpg output.webp
ffmpeg -i input.jpg output.avif

3) Using cwebp and avifenc directly

These are usually the best options.

WebP

Install cwebp (from the WebP tools package), then:

cwebp input.jpg -q 80 -o output.webp

AVIF

Install avifenc (from libavif tools), then:

avifenc --min 20 --max 50 input.jpg output.avif

You can also tune quality:

  • lower values = smaller files, lower quality
  • higher values = larger files, better quality

4) Batch convert with a shell loop

WebP

for f in *.jpg; do
  cwebp "$f" -q 80 -o "${f%.jpg}.webp"
done

AVIF

for f in *.jpg; do
  avifenc "$f" "${f%.jpg}.avif"
done

5) In JavaScript / Node.js

You can use libraries like:

  • sharp (popular, fast)
  • imagemin-webp
  • @squoosh/lib

Example with sharp:

import sharp from "sharp";

await sharp("input.jpg").webp({ quality: 80 }).toFile("output.webp");
await sharp("input.jpg").avif({ quality: 50 }).toFile("output.avif");

6) In a build pipeline

If you’re generating assets for a website, you can automate conversion in:

  • Webpack
  • Vite
  • Gulp
  • npm scripts
  • CI/CD

Example npm script:

{
  "scripts": {
    "convert": "node convert-images.js"
  }
}

7) Serving both formats on the web

Use <picture> so browsers pick the best supported format:

<picture>
  <source srcset="image.avif" type="image/avif">
  <source srcset="image.webp" type="image/webp">
  <img src="image.jpg" alt="Example">
</picture>

If you want, I can also show you:

  • the best quality/compression settings
  • how to do this on Windows/macOS/Linux
  • a Node.js batch converter script
  • how to generate responsive sizes too

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.