https://github.com/sh20raj/imgsharp
ImgSharp is a scalable image processing service that allows you to upload, transform, and serve images through a CDN, similar to Cloudinary.
https://github.com/sh20raj/imgsharp
image image-processing imgsharp sharp
Last synced: about 1 year ago
JSON representation
ImgSharp is a scalable image processing service that allows you to upload, transform, and serve images through a CDN, similar to Cloudinary.
- Host: GitHub
- URL: https://github.com/sh20raj/imgsharp
- Owner: SH20RAJ
- Created: 2025-01-11T15:52:10.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-11T15:52:13.000Z (over 1 year ago)
- Last Synced: 2025-03-22T06:32:24.456Z (over 1 year ago)
- Topics: image, image-processing, imgsharp, sharp
- Language: Python
- Homepage:
- Size: 1.07 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ImgSharp - Image Processing Service
ImgSharp is a scalable image processing service that allows you to upload, transform, and serve images through a CDN, similar to Cloudinary.
## Architecture
The service follows a serverless architecture using:
- AWS S3 for storage (original and transformed images)
- AWS Lambda for image transformations
- CloudFront as CDN
- FastAPI for the backend API
## Features
- Image upload to S3
- On-demand image transformations
- CDN delivery
- Caching of transformed images
- Support for various image operations (resize, format conversion)
## Setup
1. Clone the repository
2. Install dependencies:
```bash
pip install -r requirements.txt
```
3. Copy `.env.example` to `.env` and fill in your AWS credentials and other settings:
```bash
cp .env.example .env
```
4. Create two S3 buckets:
- One for original images
- One for transformed images
5. Set up CloudFront distribution pointing to both S3 buckets
## Running the Service
Start the FastAPI server:
```bash
uvicorn app.main:app --reload
```
## API Endpoints
### Upload Image
```
POST /upload
```
Upload an image file. Returns the URL of the uploaded image.
### Transform Image
```
GET /transform/{key}?width=400&height=400
```
Transform an image with specified parameters. Returns the URL of the transformed image.
## AWS Setup Requirements
1. S3 Buckets:
- Create two buckets: one for original images and one for transformed images
- Enable CORS on both buckets
- Set up proper bucket policies
2. CloudFront:
- Create a distribution pointing to both S3 buckets
- Configure cache behaviors
- Set up CORS headers
3. IAM:
- Create an IAM user with appropriate S3 permissions
- Generate access keys for the user
## Environment Variables
- `AWS_ACCESS_KEY_ID`: Your AWS access key
- `AWS_SECRET_ACCESS_KEY`: Your AWS secret key
- `AWS_REGION`: AWS region (e.g., us-east-1)
- `S3_BUCKET_ORIGINAL`: Bucket name for original images
- `S3_BUCKET_TRANSFORMED`: Bucket name for transformed images
- `CLOUDFRONT_DOMAIN`: Your CloudFront distribution domain