A simple API that just resizes images and returns as webp.
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 applicationPORT
: The port on which the server will runMOUNT_PATH
: The path to mount (where images will be stored)ENVIRONMENT
: The environment in which the application is runningdev
: Development environment (default, allows url to be any)
MAX_AGE
: The maximum age of the cacheS_MAX_AGE
: The maximum age of the cache for shared cachesALLOWED_ORIGINS
: The allowed origins for CORS
- JPEG
- PNG
Or any other format will be just returned as is.
- Clone the repository
- Run
cargo run
in the root directory- Or
docker compose up
to run the application in a docker container
- Or
- The server will start at
http://localhost:8100
- Send a GET request to
http://localhost:8100/v1/images/resize
with the following Query Parameters:image_url
: The URL of the image to resizewidth
: The width of the resized image (in pixels)
Image's height will be calculated based on the aspect ratio of the original image.