Stormkit includes optional image optimization capabilities that can resize and optimize images on-the-fly. This feature is opt-in and requires additional system dependencies.
Image optimization is controlled at build time using Go build tags. By default, image optimization is disabled to simplify deployment and avoid requiring additional system dependencies.
To enable image optimization, add the following environment variable
to your .env file:
GO_BUILD_TAGS=imageopt
When image optimization is enabled (with the imageopt build tag), the following system dependencies are required:
brew install vips pkg-config
apt-get update
apt-get install -y libvips-dev pkg-config
apk add --no-cache vips-dev pkgconf
The image optimization feature uses Go build tags to conditionally compile different implementations:
imageopt tag: Uses bimg library (which wraps libvips) for high-performance image processingimageopt tag: Uses a no-op implementation that returns an error when image optimization is requestedWhen image optimization is disabled:
?size= query parameters will be served without optimizationOnce built with image optimization enabled, users can request optimized images by adding query parameters:
# Resize to 300px width, auto height
GET /images/photo.jpg?size=300
# Resize to 300x200
GET /images/photo.jpg?size=300x200
# Smart crop to 300x200
GET /images/photo.jpg?size=300x200&smart=true