Prompt
What should I use to automate image optimization in a build pipeline?
Latest observation
Nov 3, 2026
OpenAI APIWeb search: off
For automating image optimization in a build pipeline, the best choice depends on your stack, but these are the most common and reliable options:
Good general-purpose tools
- Sharp (Node.js)
Fast, modern, and excellent for resizing, compressing, and converting images. Great if your build is Node-based. - ImageMagick
Very powerful and widely supported, but heavier and sometimes slower. - Squoosh CLI
Great for high-quality compression and modern formats like AVIF/WebP.
If you want simple build integration
- Webpack:
image-minimizer-webpack-plugin - Vite/Rollup: use a plugin or run a preprocessing script with Sharp
- Gulp:
gulp-imagemin - Grunt:
grunt-contrib-imagemin - CI/CD scripts: run a Node script with Sharp or Squoosh CLI
Recommended modern default
If you’re starting fresh and using Node, I’d suggest:
- Sharp for resizing/conversion/compression
- optionally pair it with SVGO for SVG optimization
- and use WebP/AVIF output for modern browsers
Typical pipeline approach
- Resize to needed dimensions
- Convert to WebP/AVIF when appropriate
- Compress JPEG/PNG
- Strip metadata
- Cache results so repeated builds are fast
Example tools by use case
- Frontend app build: Sharp + plugin for your bundler
- Static site generation: Sharp or Squoosh CLI in a prebuild step
- CI pipeline: Sharp or ImageMagick in a script
- Large asset pipeline: specialized image processing service or batch job
If you tell me your build system (Webpack, Vite, Next.js, GitHub Actions, etc.), I can recommend the exact setup and config.