Imager is a Cloudflare Images alternative written in Go. It allows you to set up an API server to upload and optimize images based on variants you define.
- Upload images via an API.
- Define custom variants for resizing and optimizing images.
- Serve optimized images on demand.
Follow these instructions to set up and run Imager on your local machine or server.
-
Clone the repository:
git clone https://github.com/shakibhasan09/imager.git cd imager
-
Build the project:
go build -o imager
-
Run the server:
./imager
The server will start on http://localhost:8080
by default.
To run Imager in a Docker container:
-
Build the Docker image:
docker build -t imager .
-
Run the container:
docker run -p 8080:8080 imager
Imager supports configuration through environment variables:
PORT
: The port the server will run on (default:8080
).UPLOAD_DIR
: Directory where uploaded images will be stored.VARIANTS
: JSON string defining the image variants (e.g.,{"thumbnail": {"width": 100, "height": 100}}
).
-
Upload an Image
Use the API endpoint/upload
to upload images:curl -X POST -F "[email protected]" http://localhost:8080/upload
-
Access Optimized Images
Access your image through the variant URL:http://localhost:8080/images/{variant}/{image_name}
Replace
{variant}
with your defined variant name and{image_name}
with the uploaded image's name.
We welcome contributions! To contribute:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Commit your changes and push them to your fork.
- Open a pull request.
Please ensure your code follows the Go coding standards and includes tests.
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to open an issue or discussion if you have any questions or suggestions.
Let me know if you'd like any changes!