A Rust HTTP server that converts images on the fly
Early development stage !!!
In common image convert adds 70-200ms to request processing time.
Variable | Allowed values | Description |
---|---|---|
url (required) |
valid url | Image url to be processed |
flip_x |
true or false |
Flip image horizontally |
flip_y |
true or false |
Flip image vertically |
grayscale |
true or false |
Make image grayscale |
blur |
floating number > 0 | Blur image |
crop |
x,y,width,height |
Crop image, x, y are coordinates of top left crop edge |
rotate |
90 or 180 or 270 |
Rotate image |
scale |
string in format <width>x<height>[:<algorithm>] , e.g. 150x100 or 150x100:cubic |
Scale image preserving aspect ratio |
format |
png , webp , avif or jpeg /jpeg:n |
Convert image to desired format. Configure JPEG quality with n, default is JPEG (quality 95) |
nearest
- Nearest neighbor interpolationtriangle
- Triangle interpolationcubic
- Catmull-Rom interpolation (Cubic interpolation)gaussian
- Gaussian interpolationlanczos3
- Lanczos3 interpolation
Run redis
docker run -p 6379:6379 redis:alpine
# with default port
docker run -p 8080:8080 -e REDIS_URL="redis://localhost:6379" thegriglat/imaginary:latest
or
# with custom port
docker run -p 8081:8081 -e PORT=8081 -e REDIS_URL="redis://localhost:6379" thegriglat/imaginary:latest
then open in browser http://localhost:8080/?url=https://upload.wikimedia.org/wikipedia/commons/b/b2/JPEG_compression_Example.jpg&blur=2&rotate=90 (change port if needed)
make build
Variable | Default | Description |
---|---|---|
PORT |
8080 | Which port Imaginary will listen |
REDIS_URL |
- | Address of redis instance to connect |
REDIS_PREFIX |
imaginary | redis prefix for imaginary entries |
REDIS_TTL |
60 | TTL in seconds for redis cache |
env REDIS_URL="redis://localhost:6379" cargo run
If you are reading this -- you know what to do.