ReImage
Fast image resizing backend based on libvips, mozjpeg and pngquant
Install / Use
/learn @ultimate-guitar/ReImageREADME
reImage
Features
- No os.exec call of pngquant or mozjpeg. Only bindings to libraries.
- Using libvips for fast image resizing
- Docker container uses libvips compiled with mozjpeg instead of libjpeg-turbo. MozJPEG makes tradeoffs that are intended to benefit Web use cases and focuses solely on improving encoding, so it's best used as part of a Web encoding workflow.
- png images are optimized with libimagequant (backend library of pngquant)
Install steps
- Deploy it with Docker
- Configure frontend
- Enjoy!
Deploy
- Pull docker container:
docker pull larrabee/reimage:1.2.5 - Run it with
docker run -d -p 7075:7075 larrabee/reimage:1.2.5or use docker-compose config:
version: '2.2'
services:
reImage:
image: larrabee/reimage:1.2.5
restart: always
ports:
- "7075:7075"
Configure frontend
This is basic Nginx config for online resizing with nginx cache.
http {
proxy_cache_path /var/www/resize_cache levels=1:2
keys_zone=resized_img:64m inactive=48h max_size=5G use_temp_path=off;
server {
listen 80;
server_name example.com;
root /var/www/example.com/;
location /img/ {
location ~* \.(jpg|jpeg|png|ico)(\@[0-9xX]+)$ {
proxy_pass http://localhost:7075; #Node with running image resizer
proxy_set_header X-RESIZE-SCHEME "http";
proxy_set_header X-RESIZE-BASE "example.com";
#Nginx cache. Optional
proxy_cache_valid 200 48h;
proxy_cache_valid 404 400 5m;
proxy_cache_valid 500 502 503 504 10s;
add_header X-Cache-Status $upstream_cache_status;
proxy_cache resized_img;
}
}
}
}
Required options:
- Replace
localhost:7075with your hostname and port if you ran resizer in different node. - Set
X-RESIZE-SCHEME "http"if your image server with original images run over http (by default use https). - Set you image server hostname here:
X-RESIZE-BASE "example.com"
Optional:
- Set
X-RESIZE-QUALITYheader if you want to override quality settings. Default value: 80, allowed values: 1-100 - Set
X-RESIZE-COMPRESSIONheader if you want to override compression settings. Default value: 6, allowed values: 0-9
Enjoy!
- Upload test image to
/img/test.jpgon your server - Get original image
http://example.com/img/test.jpg(naturally it must be present on your server). - Get resized to 1280x720 version
http://example.com/img/test.jpg@1280(height resolution will be calculate automatically) - Another way:
http://example.com/img/test.jpg@x720(width resolution will be calculate automatically) - Get resized to 500x500 version (image will be resized and striped to 500x500)
http://example.com/img/test.jpg@500x500 - Get resized to 500x500 version converted to webp (image will be resized and striped to 500x500 and converted to webp)
http://example.com/img/test.jpg@500x500?fmt=webp. Supported formats: jpeg (or jpg), png, webp, tiff. - Get resized to 500x500 version with custom compression (image will be resized and striped to 500x500)
http://example.com/img/test.jpg@500x500?cmp=9. Compression value range: from 0 to 9. - Get resized to 500x500 version with custom quality (image will be resized and striped to 500x500)
http://example.com/img/test.jpg@500x500?qlt=100. Quality value range: from 0 to 100. - Get resized to 500x500 version with custom background color
http://example.com/img/test.jpg@500x500?bgclr=003cfa. Format: RGB in HEX encoding, like "ffffff" for white. Default: "000000" for none.
Benchmark
LICENSE
MIT
Related Skills
node-connect
339.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
xurl
339.3kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
frontend-design
83.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
339.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
