Skip to content

thegriglat/imaginary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Imaginary

A Rust HTTP server that converts images on the fly

Early development stage !!!

In common image convert adds 70-200ms to request processing time.

Query parameters

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 180or 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)

Supported algorithms for scaling

  • nearest - Nearest neighbor interpolation
  • triangle - Triangle interpolation
  • cubic - Catmull-Rom interpolation (Cubic interpolation)
  • gaussian - Gaussian interpolation
  • lanczos3 - Lanczos3 interpolation

Deployment

Run redis

docker run -p 6379:6379 redis:alpine

Using Docker Hub image

# 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)

Build your own image

make build

Environment variables

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

Local development

env REDIS_URL="redis://localhost:6379" cargo run 

If you are reading this -- you know what to do.