https://github.com/retheviper/resize-api
Image Resize API
https://github.com/retheviper/resize-api
actix-web image-processing rust
Last synced: 10 months ago
JSON representation
Image Resize API
- Host: GitHub
- URL: https://github.com/retheviper/resize-api
- Owner: retheviper
- Created: 2024-03-20T14:24:14.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-20T14:46:46.000Z (over 2 years ago)
- Last Synced: 2025-04-13T08:56:15.018Z (about 1 year ago)
- Topics: actix-web, image-processing, rust
- Language: Rust
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Image resize API
## TL;DR
A simple API that just resizes images and returns as webp.
## Description
Actix-web based API that resizes images.
Using the `image` crate, the API downloads the image from the provided URL, resizes it to the specified width, and returns the resized image.
Set `.env` file with the following environment variables:
- `RUST_LOG`: The log level for the application
- `PORT`: The port on which the server will run
- `MOUNT_PATH`: The path to mount (where images will be stored)
- `ENVIRONMENT`: The environment in which the application is running
- `dev`: Development environment (default, allows url to be any)
- `MAX_AGE`: The maximum age of the cache
- `S_MAX_AGE`: The maximum age of the cache for shared caches
- `ALLOWED_ORIGINS`: The allowed origins for CORS
## Supported image formats (to be resized)
- JPEG
- PNG
Or any other format will be just returned as is.
## How to run
1. Clone the repository
2. Run `cargo run` in the root directory
1. Or `docker compose up` to run the application in a docker container
3. The server will start at `http://localhost:8100`
4. Send a GET request to `http://localhost:8100/v1/images/resize` with the following Query Parameters:
- `image_url`: The URL of the image to resize
- `width`: The width of the resized image (in pixels)
Image's height will be calculated based on the aspect ratio of the original image.