Giter Club home page Giter Club logo

go-http-image-manipulation's Introduction

go-http-image-manipulation

HTTP Implementation of Image Manipulation using Golang and OpenCV

Basic Instructions

  • Installation
    • Install latest Golang version (e.g. go1.21.x)
    • Install OpenCV => >= 4.7.x
    • Install application dependencies
      • Run go mod download to download dependencies
      • Run go mod vendor to set dependencies into project directory
  • Build Project
    • Run go build . (the binary output => go-http-image-manipulation)
  • Run HTTP Service
    • From Source => go run server.go
    • From Binary => ./go-http-image-manipulation
  • Unit Tests
    • Normal test => run go test ./...
    • Test with coverage result => run go test ./... -cover
    • Test and generate test coverage report (HTML) => go test ./... -coverprofile=c.out && go tool cover -html=c.out -o coverage.html
    • Test specific package => run go test {package_name}
      • Example: go test "github.com/vafrcor/go-http-image-manipulation/services"
    • Test specific package test case => run go test {package_name} -run {name_of_test}
      • Example: go test "github.com/vafrcor/go-http-image-manipulation/services" -run TestGetEchoRequestScheme

Endpoint Tests

Convert image files from PNG to JPEG

  • URL: [POST] http://localhost:9000/image-png-to-jpeg

  • Request

    • Content Type: multipart/form-data
    • Fields:
    Name Mandatory Description
    file yes image file (image/png)
  • Response

    • Content Type: application/json
    • Fields:
    Name Type Description
    message string detailed message (for both success and error)
    status boolean true or false
    data string output path (for preview)
    • Examples:

      • Success
      {
          "message": "Ok",
          "status": true,
          "data": "http://localhost:9000/static/small-1710681145040310000-100.jpeg"
      }
      • Error
      {
          "message": "only accept image using specific format (png)",
          "status": false,
          "data": null
      }

Resize images according to specified dimensions

  • URL: [POST] http://localhost:9000/image-resize

  • Request

    • Content Type: multipart/form-data
    • Fields:
    Name Mandatory Description
    file yes image file (image/png, image/jpg, image/jpeg, image/bmp)
    width yes desired width (in pixel)
    height yes desired height (in pixel)
    keep_aspect_ratio no 1 or 0
  • Response

    • Content Type: application/json
    • Fields:
    Name Type Description
    message string detailed message (for both success and error)
    status boolean true or false
    data string output path (for preview)
    • Example:
      • Success
      {
          "message": "Ok",
          "status": true,
          "data": "http://localhost:9000/static/medium-1710685243638707000-100.png"
      }
      • Error
      {
          "message": "only accept image using specific format (png,jpg,jpeg)",
          "status": false,
          "data": null
      }

Compress images to reduce file size while maintaining reasonable quality

  • URL: [POST] http://localhost:9000/image-compression

  • Request

    • Content Type: multipart/form-data
    • Fields:
    Name Mandatory Description
    file yes image file (image/png, image/jpg, image/jpeg, image/bmp)
    quality yes desired quality (1 - 100)
  • Response

    • Content Type: application/json
    • Fields:
    Name Type Description
    message string detailed message (for both success and error)
    status boolean true or false
    data string output path (for preview)
    • Example:
      • Success
      {
          "message": "Ok",
          "status": true,
          "data": "http://localhost:9000/static/medium-1710686662823893000-70.jpeg"
      }
      • Error
      {
          "message": "http: no such file",
          "status": false,
          "data": null
      }

References

Others

go-http-image-manipulation's People

Contributors

vafrcor avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.