A high-performance, lightweight image processing proxy server written in Go. It fetches images from remote URLs, resizes, compresses, and converts them on-the-fly using libvips (via bimg).
This project uses the Go standard library (net/http) for maximum efficiency and minimal dependencies.
- 🚀 High Performance: Powered by
libvips, one of the fastest image processing libraries available. - 🖼 Format Conversion: Convert images to WebP, JPEG, PNG, or GIF on the fly.
- 📏 Resizing: Smart resizing with width and height parameters.
- 🎨 Quality Control: Adjustable compression quality for optimization.
- 🐳 Docker Ready: Includes a multi-stage Dockerfile for small production images (Alpine based).
- ⚙️ Configurable: Easy configuration via
config.yml.
If running locally (without Docker), you must have libvips installed on your system, as bimg uses C bindings.
brew install vipssudo apt-get install libvips-devClone the repository and install dependencies:
git clone https://github.com/sametasci/go-image-proxy.git
cd go-image-proxy
go mod downloadRun the server:
go run main.goYou can build and run the application using Docker, which handles the libvips dependency automatically.
# Build the image
docker build -t go-image-proxy .
# Run the container (mapping port 8080)
docker run -p 8080:8080 go-image-proxyConfiguration is handled in config.yml.
| Key | Default | Description |
|---|---|---|
server.port |
8080 |
Port the server listens on |
fetch.timeout_ms |
2500 |
Timeout in ms for fetching remote images |
image.default_quality |
80 |
Default image quality (1-100) |
image.default_format |
webp |
Default output format if none specified |
image.default_width |
800 |
Fallback width if parsing fails |
image.default_height |
800 |
Fallback height if parsing fails |
| Parameter | Type | Required | Description |
|---|---|---|---|
url |
string | Yes | The full URL of the source image |
w |
int | No | Target width |
h |
int | No | Target height |
q |
int | No | Quality (1-100). Default: 80 |
format |
string | No | Output format (webp, jpg, png, gif) |
1. Simple conversion to WebP (using defaults):
http://localhost:8080/image?url=https://example.com/image.jpg
2. Resize to 300px width and convert to JPEG:
http://localhost:8080/image?url=https://example.com/image.png&w=300&format=jpg
3. Resize to 100x100 with 90% quality:
http://localhost:8080/image?url=https://example.com/photo.jpg&w=100&h=100&q=90
MIT