The sole purpose of this application is to scale images on demand via URL. It supports header and memory cache.
It is similiar to the Piuma Custom project.
Rust language allows for more performance oriented approach than Golang.
This is not production ready yet - if you are interested in more wholesome solution - use Piuma Custom for now.
Docker image is available here: https://hub.docker.com/r/lucassith/pixvert_rs
- Fetching images from external source and Cache them with ETAG and/or Modified-Since Headers.
- Decoding PNG/JPEG images.
- Scaling images via URL params to a given resolution.
- Encoding scaled images to WEBP.
Clone this repo and run:
cargo run --release
Application is then ready and you will be able to execute HTTP request.
Having an image resource available under: https://via.placeholder.com/150x100
You must first do URI Encode the string to: https%3A%2F%2Fvia.placeholder.com%2F150x100
Decode: PNG
, JPG
Encode: PNG
, JPG
, WEBP
, JPEG-XL
If you want to cache the image, you can execute following request
curl localhost:8080/{encoded url}
example
curl localhost:8080/https%3A%2F%2Fvia.placeholder.com%2F150x100
As a response you will receive exact same image but served from cache.
You can change the file format using following request:
curl localhost:8080/{format}/{url}
example
curl localhost:8080/webp/https%3A%2F%2Fvia.placeholder.com%2F150x100
As a response you will receive webp encoded image.
You can change the file format using following request:
curl localhost:8080/{width}_{height}/{url}
example
curl localhost:8080/100_400/https%3A%2F%2Fvia.placeholder.com%2F150x100
As a response you will receive a scaled image (it will not be exactly 100x400 since the image keeps the ratio)
You can change the file format using following request:
curl localhost:8080/{width}_{height}/webp/{url}
example
curl localhost:8080/100_400/webp/https%3A%2F%2Fvia.placeholder.com%2F150x100
- Handle Cache-Control header when fetching external image.
- Implement
quality
parameter. - Implement keeping aspect ratio.
- Implement Cache-Control for response.
- Configuration file.
- Implement JPEG-XL for encoding.
- Implement JPEG-XL for decoding.
- Maximum output file pixels