- Notifications
You must be signed in to change notification settings - Fork0
daniwebdev/image-compressor-api
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Image Compressor API is a simple HTTP service written in Go that allows you to compress and resize images from a given URL. It supports popular image formats such as JPEG, PNG, and WebP.
- Image compression and resizing based on provided parameters.
- Automatic determination of the image format based on the URL's content type.
- Support for JPEG, PNG, and WebP output formats.
- Option to specify output quality and resolution.
- Efficient caching: If the compressed image already exists, it is served without re-compression.
- Go (Golang) installed on your machine.
- mux,nfnt/resize, andchai2010/webp Go packages.
Clone the repository:
git clone https://github.com/yourusername/your-repo.gitcd your-repoInstall dependencies:
go get -u github.com/gorilla/muxgo get -u github.com/nfnt/resizego get -u github.com/chai2010/webp
Build and run the project:
go run*.go -o ./tmpAlternatively, for a production build:
go build -o image-compressor./image-compressor -o ./tmp
To compress an image, make a GET request to the/compressor endpoint with the following parameters:
url: URL of the image to be compressed.output: Desired output format (e.g., "jpeg", "png", "webp").quality: Output quality (0-100, applicable for JPEG).resolution: Output resolution in the format "widthxheight" (e.g., "1024x720").
Example:
curl"http://localhost:8080/compressor?url=https://example.com/image.jpg&output=webp&quality=80&resolution=1024x720"- Method: GET
- Parameters:
url(required): URL of the image to be compressed.output(optional): Desired output format (e.g., "jpeg", "png", "webp").quality(optional): Output quality (0-100, applicable for JPEG).resolution(optional): Output resolution in the format "widthxheight" (e.g., "1024x720").
Example:
curl"http://localhost:8080/compressor?url=https://example.com/image.jpg&output=webp&quality=80&resolution=1024x720"This project is licensed under theMIT License.
About
Image Compressor API is a simple HTTP service written in Go that allows you to compress and resize images from a given URL. It supports popular image formats such as JPEG, PNG, and WebP.
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.