To deploy compressed static image files, add a build step that reads original images and writes optimized copies to a separate output directory, then make sure your site build and deployment package that directory. If you need images transformed only when visitors request them, use a framework runtime optimizer or a hosted image service instead; neither necessarily creates optimized files in the build artifact.
Choose when images should be transformed
“Image optimization” can mean three different things: generating compressed files during a build, transforming images at request time on your own server, or delivering transformed images through a hosted service. Decide based on what you need to deploy and how the site is hosted.
As an Amazon Associate I earn from qualifying purchases.
| Approach | When transformation happens | What deployment receives | Main operational concern |
|---|---|---|---|
| Build-time CLI or API | During the build step | Generated image files in the build artifact | Encoder/plugin configuration, output paths, and quality checks |
| Framework runtime optimizer | When images are requested | Optimized responses or cached variants, not necessarily build-generated files | Runtime support, CPU and memory use, and framework or platform behavior |
| Hosted transformations | In the hosted image-delivery flow | Transformed URLs or responses | Service configuration, caching, delivery behavior, and terms |
Build compressed files into the deployment artifact
For a static site or asset pipeline, keep original images separate from generated output. Add an image-optimization command before the site bundler or deployment-packaging step, and configure the site to use the generated directory.
imagemin 'images/*' --out-dir=build/images
The imagemin CLI documents file paths or glob inputs and an output directory. Its documentation also shows selecting a plugin, such as --plugin=pngquant, and configuring plugin options; the API accepts path or glob inputs, a destination directory, and plugins. See the imagemin CLI documentation.
#1 Best Overall
- ✔️ AI Upscaling up to 8K: Enlarge small, low-resolution, or old photos with crisp details, clean edges, and fewer artifacts — perfect for prints, social media, blogs, and online galleries.
- ✔️ Fix blurry or noisy photos: AI restores clarity by enhancing textures, sharpening faces, hair, and fine details while reducing noise and JPEG compression errors.
- ✔️ Ideal for family photos, scans & mobile images: Improve pictures from smartphones, tablets, digital cameras, scanners, and old archives with professional-quality results.
- ✔️ Fast & easy 1-click enhancement: Batch-process multiple photos at once and improve image quality instantly — no editing experience required.
- ✔️ Reliable results & broad file support: Works with JPG, PNG, TIFF and more — stable AI processing even on old, compressed or damaged photos.
This is a starting pattern, not a universal quality preset. Choose lossy or lossless processing, format conversion, quality, metadata handling, and resize limits for your assets. Photographs, logos, and screenshots may need different treatment; the documentation does not establish one setting that is best for every image or repository. Preserve originals where possible so you can change settings without recompressing already-lossy outputs.
Wire the step into the build
- Choose source and destination directories. For example, read originals from
images/and write generated assets tobuild/images. Do not use the generated directory as the source for the next run. - Run compression before packaging. Put the command in the build sequence before the site bundler or deployment packaging step that needs the resulting assets.
- Point the site at generated files. Check that pages and CSS reference the output path, not the unprocessed originals.
- Include the output in deployment. Confirm that the deploy step packages and publishes the generated directory. A successful compression command alone does not ensure those files reach production.
- Check the result. Add project-appropriate checks that expected output files exist and representative images render. If CI caches build outputs, ensure a cache cannot leave stale generated files in the artifact.
Use runtime optimization only when hosting supports it
A framework optimizer may transform images as visitors request them rather than during the build. In its Next.js 14 deployment documentation, Next.js states: “Note that images are optimized at runtime, not during the build.” The page was last updated March 13, 2024; consult the Next.js 14 deployment documentation for the version-specific behavior.
Rank #2
For a self-hosted Next.js server, the same documentation recommends considering Sharp for more performant production image optimization and notes that Linux may require additional configuration to avoid excessive memory use. Sharp’s installation guidance says package managers select a matching prebuilt binary for the current operating system and CPU architecture where available. Its documented input formats include JPEG, PNG, Ultra HDR, WebP, AVIF, TIFF, GIF, and SVG. See Sharp installation guidance.
If CI builds on one operating system or architecture and the deployed runtime uses another, follow Sharp’s cross-platform installation guidance rather than assuming the workstation’s binary will work in the deployment image. Runtime optimization also requires an environment that supports the framework’s runtime behavior; it is not a substitute for files that must already exist as compressed static assets.
Rank #3
Account for static export and deployment mode
Next.js 14 supports a custom image loader for Image Optimization with static export. Its documentation distinguishes that from a Node.js deployment using next start, which supports the framework’s features. For static-only hosting, choose a build-time compressor or a compatible external loader; do not expect the built-in server optimizer to materialize every image variant in a static build. See the Next.js 14 deployment documentation and its static export documentation.
Current Next.js self-hosting documentation also describes runtime optimization and notes that separately optimizing images yourself is one reason to disable the built-in optimizer while retaining other next/image benefits. Check the documentation for the Next.js version and hosting mode you actually deploy: the version 14 deployment details above are explicitly version-specific.
Rank #4
Use hosted transformations for URL-based delivery
A hosted image service can transform assets in its delivery flow rather than emitting compressed files in your build. Cloudinary documents q_auto for automatic quality selection and f_auto for automatic format selection; its Next.js SDK documentation describes applying these optimizations to transformed image URLs. The documentation says default optimizations affect delivered images while leaving original files unchanged. See Cloudinary image optimization and Cloudinary Next.js image transformations.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11This model fits a project whose image sources and delivery flow can use hosted transformations and CDN URLs. Before choosing it, verify that URL-based delivery meets your requirements for build artifacts, caching, privacy, and operations. Automatic delivery optimization is not evidence that the build emitted optimized image files.
Quick Recap
Best Value
- EVERY PDF TOOL UNLOCKED - 30+ tools in one app: edit text and images, convert, merge, split, compress, sign, OCR, redact, watermark, batch process, and more. No feature gates, no upsells, nothing held back.
- PAY ONCE, OWN FOREVER — A one-time purchase, not a subscription. Other apps runs $240/year — Scrivar is yours for life, with free updates included.
- UNLIMITED eSIGN, BUILT IN — Send contracts and forms for signature and track every step. Recipients sign in their browser with no account or app needed. Replace DocuSign and save hundreds a year.
- PC, MAC, AND WEB — Install on any Win 10/11 PC or macOS 11+ Mac (Intel or Apple Silicon), or work in your browser at scrivar.com. Same tools, same account, everywhere you work.
- OCR + FULL OFFICE CONVERSION — Turn scanned documents into searchable, selectable text, and convert PDFs to and from Word, Excel, and PowerPoint with formatting kept intact.
Check pipeline and deployment compatibility
- Static asset deployment: generate files into a known output directory and verify that the deploy step includes it.
- Runtime optimization: verify that the deployed framework and host support the optimizer, and account for runtime CPU and memory needs.
- Native dependencies: for Sharp, match installation to the target OS and CPU architecture, especially when CI and production differ.
- Static export: use a custom loader or build-time processing where required instead of expecting a server-side optimizer in static output.
- Quality control: select settings for the image types in the project and review representative results; no universal setting is established for all asset types.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




