A RESTful API for converting images between various formats.
- JPEG (.jpg, .jpeg)
- PNG (.png)
- GIF (.gif)
- WebP (.webp)
- TIFF (.tif, .tiff)
- BMP (.bmp)
- SVG (.svg)
- HEIF (.heif, .heic)
- RAW (Digital Camera Format)
- EPS (.eps)
- PSD (Photoshop)
- AI (Adobe Illustrator)
- PDF (.pdf)
- ICO (.ico)
- PCX (.pcx)
- JXR (.jxr)
- TGA (.tga)
- PPM (.ppm)
- XCF (GIMP)
- DXF (.dxf)
Depending on the input format, the API can convert to various formats including:
- JPEG
- PNG
- GIF
- WebP
- TIFF
- BMP
- SVG
- EPS
- Clone the repository
- Install dependencies:
pip install -r requirements.txt - Install system dependencies:
- For SVG support: Cairo graphics library
- For PDF support: Poppler
- For RAW support: LibRaw
- For AI/EPS support: Ghostscript
- For HEIF support: libheif
-
Start the server:
python app/app.py -
Make a POST request to
/convertwith:- An image file
- Target format parameter
Example using curl:
curl -X POST -F "image=@path/to/image.jpg" -F "target_format=png" http://localhost:5000/convert
Converts an uploaded image to the specified format.
Parameters:
image: The image file to converttarget_format: The desired output format (e.g., "png", "jpg", "webp")quality(optional): For lossy formats, the quality level (1-100)
Response:
- The converted image file
docker build -t image-converter-api .
docker run -p 5000:5000 image-converter-api-
Create a Render account at render.com
-
Connect your GitHub repository to Render:
- Go to the Render dashboard
- Click "New" and select "Web Service"
- Connect your GitHub repository
-
Configure the service:
- Name: Choose a name for your service (e.g., image-converter-api)
- Environment: Docker
- Branch: main (or your preferred branch)
- Plan: Free (or choose a paid plan for more resources)
- Advanced Settings: Add any environment variables if needed
-
Click "Create Web Service"
Render will automatically build and deploy your application. The deployment process may take a few minutes.
Alternatively, you can use the provided render.yaml file for deployment:
- Push your code to GitHub
- In Render dashboard, go to "Blueprints"
- Connect your repository
- Render will detect the
render.yamlfile and set up the services accordingly
If you encounter import errors during deployment, make sure:
- Your import statements use absolute imports (e.g.,
from app.services.converter import ImageConverter) - The
PYTHONPATHenvironment variable is set to/appin both Dockerfile and render.yaml - The gunicorn command in Dockerfile explicitly changes to the
/appdirectory before starting
MIT