Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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.

NotificationsYou must be signed in to change notification settings

daniwebdev/image-compressor-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

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.

Features

  • 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.

Getting Started

Prerequisites

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/your-repo.gitcd your-repo
  2. Install dependencies:

    go get -u github.com/gorilla/muxgo get -u github.com/nfnt/resizego get -u github.com/chai2010/webp
  3. Build and run the project:

    go run*.go -o ./tmp

    Alternatively, for a production build:

    go build -o image-compressor./image-compressor -o ./tmp

Usage

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"

API Endpoints

/compressor

  • 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"

License

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

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp