Meet Image Optimizer in Compute: Flexible Image Workflows at the Edge

Staff Product Manager, Fastly

Today, we’re excited to announce that Fastly Image Optimizer (IO) is now available through the Fastly Compute SDKs in Beta. This release represents a significant leap forward in how you can architect and deliver image optimization workflows, giving you unprecedented flexibility and control over your image transformation pipelines, at the edge and at scale.
What is Image Optimizer in Fastly Compute?
Fastly Image Optimizer has been a cornerstone of our Delivery platform, helping customers automatically optimize and transform images at the edge. With today’s release, we’re extending IO’s capabilities to Fastly Compute, our powerful serverless compute environment.
Image Optimizer in Compute enables you to build Compute applications that interface directly with Fastly IO for image transformations. This means you can now programmatically orchestrate image optimization as part of sophisticated application logic, all at the edge.
It’s important to note that image transformations themselves are still performed by Fastly’s dedicated Image Optimizer service—what’s new is your ability to integrate these transformations seamlessly into Compute applications, unlocking powerful new architectural patterns.
IO in Compute works alongside our existing IO in Delivery offering, giving you the flexibility to choose the right approach for your use case.
Why This Matters: More Control, Less Complexity
Traditional image optimization workflows often force you into rigid patterns. With IO in Delivery, transformations follow a fixed order of operations. If you need more complex logic – conditional transformations, custom processing sequences, or integration with other services – you’ve historically needed workarounds like service chaining or complex VCL configurations.
Image Optimizer in Compute removes these constraints. By bringing access to IO capabilities into the Compute environment, you gain the freedom to build image optimization workflows that work with your requirements, not the other way around.
Key Benefits of Image Optimizer in Compute
Build Advanced, Multi-Layered Workflows
With IO in Compute, image transformations become first-class citizens in your application logic. You can combine image optimization with authentication checks, A/B testing, personalization logic, database queries, or calls to external APIs – all in a single, cohesive workflow.
Example: Dynamically select image transformations based on user preferences stored in a database, apply device-specific optimizations based on real-time device detection, and log transformation metrics to your analytics platform – all in one Compute application.
Use the Languages You Love
Fastly Compute supports multiple programming languages, including Rust, JavaScript, and Go. With IO in Compute, you can implement image optimization logic using these modern languages – no VCL required.
This means more developers on your team can contribute to image optimization workflows using familiar tools and patterns, accelerating development and reducing the learning curve.
Simplify Your Architecture
IO in Compute provides direct access to image transformation capabilities without requiring Fastly Delivery or complex service chaining configurations. This simplification means:
Fewer moving parts to manage and monitor
Reduced configuration complexity
More straightforward debugging and troubleshooting
Lower operational overhead
Real-World Use Cases for IO in Compute
Let’s look at some scenarios where IO in Compute shines:
Standalone Image Processing Pipelines
Build dedicated image processing services that handle transformations independently from your content delivery pipeline. Perfect for workflows where images need preprocessing before storage or distribution through other channels.
Conditional Optimization Based on Context
Apply different transformation strategies based on user agent, geolocation, subscription tier, or any other contextual information. For example, serve high-quality images to premium users while applying more aggressive optimization for free-tier users—all with custom logic you control.
Conditional Transformations with Business Logic
Apply transformations to images based on conditional factors internal or external to source content, implement content moderation checks before final delivery, and more.
Integration with other Services
Seamlessly combine IO transformations with calls to external APIs, content management systems, and other parts of your business. Build rich media workflows that leverage the best tools for each job.
Getting Started
Ready to start building with IO in Compute? Here is a simple example in Rust and Go to get you started:
use fastly::image_optimizer::{ImageOptimizerOptions, ImageOptimizerRegion};
use fastly::{Error, Request, Response};
use regex::Regex;
#[fastly::main]
fn main(mut req: Request) -> Result<Response, Error> {
let image_regex = Regex::new(r"(?i)(?:gif|png|jpe?g|webp|avif|jxl|heic)\z").unwrap();
let url_path = req.get_path();
// Only images go to Image Optimizer using the regex above or assuming an images directory
if url_path.contains("/images/") || image_regex.is_match(url_path) {
let io_options = ImageOptimizerOptions::from_region(ImageOptimizerRegion::UsWest);
req = req.with_image_optimizer(io_options);
return Ok(req.send("origin")?);
}
// all other requests go to the normal path
Ok(req.send("origin")?)
} package main
import (
"context"
_ "embed"
"fmt"
"github.com/fastly/compute-sdk-go/fsthttp"
"github.com/fastly/compute-sdk-go/fsthttp/imageopto"
"io"
"regexp"
)
var imgRegex = regexp.MustCompile(`(?i)\.(?:gif|png|jpe?g|webp|avif|jxl|heic)$`)
func main() {
fsthttp.ServeFunc(func(ctx context.Context, w fsthttp.ResponseWriter, r *fsthttp.Request) {
if imgRegex.MatchString(r.URL.Path) {
// Proxy request to image optimizer if we are dealing with an image.
r.ImageOptimizerOptions = &imageopto.Options{
Region: imageopto.RegionUsWest,
}
}
// `origin` is a named backend on the service.
// Requests with `ImageOptimizerOptions` are proxied through to Image Optimizer.
// The other requests are sent to the `origin` backend directly.
resp, err := r.Send(ctx, "origin")
if err != nil {
w.WriteHeader(fsthttp.StatusBadGateway)
fmt.Fprintln(w, err)
return
}
w.Header().Reset(resp.Header.Clone())
io.Copy(w, io.NopCloser(resp.Body))
})
} For complete documentation, code samples, and best practices, visit our Compute documentation and Image Optimizer reference guide.
What This Means for Your Business
Beyond the technical benefits, IO in Compute delivers real business value:
Faster time to market. Build and deploy sophisticated image workflows without architectural constraints.
Improved user experience. Deliver optimized images tailored to each user’s context.
Reduced costs. Simplify your architecture and eliminate unnecessary service complexity.
Greater innovation. Experiment with new image optimization strategies without platform limitations.
Start Building Today
Fastly Image Optimizer in Compute is available now in Beta through the Compute SDKs. For customers already contracted on IO and Compute, you can start using them together today. Just let us know, and we will switch it on for you! We bill IO requests in aggregate, whether you are using IO with CDN or Compute services. If you’re building a new application or enhancing an existing workflow, IO in Compute gives you the power and flexibility to deliver exceptional image experiences.
We can’t wait to see what you build. Get started with IO today, and as always, we welcome your feedback and questions. Reach out to your account team or visit our developer community to share your experiences and learn from other developers.