An open API service indexing awesome lists of open source software.

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.

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