This is an API for image conversion, built using Go and the Gin framework.
The API documentation is generated using Swagger/OpenAPI and can be accessed at the following endpoint: ImageX Docs
-
Clone the repository:
git clone https://github.com/Powerisinschool/image-x.git
-
Install the dependencies:
go mod download
-
Start the API server:
go run main.go
-
Access the API endpoints using a REST client or tools like cURL or Postman.
POST /api/convert
: Convert image format.POST /api/resize
: Resize image.POST /api/filter
: Apply filter to image.POST /api/crop
: Crop image.POST /api/rotate
: Rotate image.POST /api/compress
: Compress image.POST /api/thumbnail
: Generate thumbnail image.
Convert the image format by sending a POST request to '/api/convert' endpoint with the following parameters:
file
: Image file to convert (multipart/form-data)format
: Target format to convert to (multipart/form-data)
Example request using cURL:
curl -X POST -F "file=@/path/to/image.jpg" -F "format=png" https://imagex.toluolagunju.tech/api/convert
Resize the image by sending a POST request to '/api/resize' endpoint with the following parameters:
file
: Image file to resize (multipart/form-data)width
: Target width for resizing (multipart/form-data)height
: Target height for resizing (multipart/form-data)quality
: Quality level for resizing. Options:low
,medium
,high
,best
(multipart/form-data)
Example request using cURL:
curl -X POST -F "file=@/path/to/image.jpg" -F "width=800" -F "height=600" -F "quality=high" https://imagex.toluolagunju.tech/api/resize
Apply the specified filter to the image by sending a POST request to '/api/filter' endpoint with the following parameters:
file
: Image file to apply the filter (multipart/form-data)filter
: Filter to apply: grayscale, sepia, blur, sharpen (multipart/form-data)
For the blur
filter, you can also specify the blur radius using the radius
query parameter (Defaults to 2).
Example request using cURL:
curl -X POST -F "file=@/path/to/image.jpg" -F "filter=grayscale" https://imagex.toluolagunju.tech/api/filter
Note: The supported filters are 'grayscale', 'sepia', 'blur', and 'sharpen'.
The response will be the filtered image.