Optimagio

Image Proxy Setup: Dynamic Transformation at the Edge

Learn how to configure edge-based image proxies for on-the-fly optimization, reducing origin load and accelerating delivery.

Optimagio Team 5 min read
Image Proxy Setup: Dynamic Transformation at the Edge

Traditional image optimization often happens at the origin server—resizing uploads, generating thumbnails, and converting formats during content creation. This approach creates storage overhead, complicates development workflows, and delivers static assets that can't adapt to different devices or network conditions. Edge-based image proxies flip this model by processing images on-demand at CDN locations worldwide, transforming them dynamically based on URL parameters and client capabilities. This article guides you through implementing an image proxy setup that handles resizing, format conversion, and compression at the edge, reducing origin load while accelerating delivery.

How Edge Image Proxes Work

Edge image proxies intercept requests for images, parse transformation parameters from the URL or headers, process the image at the CDN edge location, and serve the optimized result. The first request fetches the original image from your origin and applies transformations, while subsequent requests serve the processed version from edge cache.

  1. 1Request InterceptionCDN intercepts image request containing transformation parameters
  2. 2Cache CheckChecks if transformed version exists in edge cache
  3. 3Origin FetchIf not cached, fetches original image from origin server
  4. 4TransformationApplies resizing, format conversion, compression at edge
  5. 5Cache StorageStores optimized version in edge cache for future requests
  6. 6DeliveryServes optimized image to client with appropriate headers
Reduced Origin LoadOnly fetch originals once per transformation combination, not per request
Global PerformanceProcess and serve images from locations closest to users worldwide
Dynamic AdaptationServe different sizes and formats based on device, viewport, or network conditions

Common Transformation Parameters

Image proxies typically use URL parameters to specify transformations. While implementations vary, most support similar parameters for controlling size, format, quality, and other processing options.

width / w
Target width in pixels (maintains aspect ratio if height not specified)
height / h
Target height in pixels
quality / q
Compression quality (0-100), often with smart defaults per format
format / fm
Output format (jpg, png, webp, avif, auto)
crop
Cropping mode (fit, fill, crop, scale, smart)
rotate
Rotation angle in degrees

Implementation Approaches

You can implement edge image processing through various approaches, from managed services to self-hosted solutions. Each option has different tradeoffs in terms of control, cost, and maintenance overhead.

CDN-Native SolutionsServices like Cloudflare Images, ImageKit, or Cloudinary provide integrated image processing within their CDN platforms. Easy setup but limited to their specific feature set and pricing model.
Self-Hosted ProxiesSolutions like imgproxy, Thumbor, or Imaginary run on your own infrastructure. Maximum control and customization but require maintenance and scaling expertise.
Serverless Edge FunctionsUse platforms like Vercel OG Image, Netlify Image CDN, or AWS Lambda@Edge with sharp.js. Flexible and pay-per-use but requires more development effort.
Managed Services
  • ProsQuick setup, no maintenance, global infrastructure
  • ConsVendor lock-in, recurring costs, limited customization
Self-Hosted
  • ProsFull control, one-time cost, complete customization
  • ConsMaintenance overhead, scaling challenges, infrastructure costs

Configuration Best Practices

Proper configuration ensures your image proxy delivers optimal performance while preventing abuse and managing costs effectively. These practices apply regardless of your chosen implementation approach.

  • Implement caching headers
  • Set reasonable size limits
  • Enable automatic format negotiation
  • Configure quality defaults per format
  • Set up monitoring and analytics
  • Implement rate limiting
  • Use signed URLs for sensitive content

Advanced Techniques

Beyond basic resizing and format conversion, advanced proxy configurations can handle responsive images, automatic optimization, and intelligent cropping.

Responsive Images with srcsetGenerate multiple sizes automatically and use srcset to let browsers choose the appropriate version based on viewport and pixel density.
Automatic Quality AdjustmentDynamically adjust compression quality based on image content—lower quality for simpler images, higher for complex photographs.
Smart CroppingUse face detection or saliency analysis to intelligently crop images while preserving important content.
Background RemovalAdvanced proxies can remove backgrounds on-the-fly for product images or create consistent styling across varied source images.

Testing and Monitoring

After implementing your image proxy, thorough testing ensures it performs correctly across various scenarios. Monitor key metrics to identify issues and optimize performance over time.

  1. 1Test format supportVerify WebP/AVIF serve correctly to supported browsers with proper fallbacks for others
  2. 2Check responsive behaviorTest different viewports and devices to ensure appropriate sizes are delivered
  3. 3Verify caching headersConfirm Cache-Control, ETag, and Last-Modified headers are set correctly
  4. 4Monitor origin requestsEnsure only missing transformations trigger origin fetches, not every request
  5. 5Track performance metricsMonitor LCP improvements, bandwidth savings, and transformation latency

Automate image optimization with Optimagio

Doing this by hand for every image does not scale. Optimagio optimizes and converts your images (WebP and AVIF) automatically across your API, web app, and CMS — so every page ships the smallest possible files without manual work. See plans and pricing →

FAQ

Frequently asked questions

What is an image proxy?

An image proxy is a server that processes image transformations on-the-fly, typically resizing, cropping, format conversion, and compression, before delivering the optimized result to the client.

How does edge-based image optimization differ from server-side processing?

Edge processing occurs at CDN locations worldwide, closer to end-users, reducing latency and origin server load. Server-side processing happens at your origin, adding overhead and increasing response times for distant users.

What image formats should I serve through an image proxy?

Serve modern formats like WebP and AVIF to supported browsers, with JPEG/PNG fallbacks. Most edge proxies automatically handle format negotiation based on the Accept header.

How do I prevent abuse of my image proxy?

Implement rate limiting, signed URLs, domain restrictions, and size limits to prevent malicious usage and excessive resource consumption.

Can I use image proxies with existing CMS platforms?

Yes, most modern CMS platforms support image proxy integration through plugins or custom configuration, allowing you to maintain existing workflows while benefiting from edge optimization.

Keep reading