pradeep-mishra / gomage

Image optimisation server written in golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gomage

Image optimisation server written in golang

Third party libraries used
  • "github.com/davidbyttow/govips/v2/vips"
  • "github.com/fatih/structs"
  • "github.com/go-playground/validator/v10"
  • "github.com/gofiber/fiber/v2"
Requirements
  • libvips 8.10+
  • C compatible compiler such as gcc 4.6+ or clang 3.0+
  • Go 1.14+

API usage

GET http://localhost:3300/v1/optimize/s.jpg?filters

Check api usage with sample.jpg file

http://localhost:3300/v1/optimize/s.jpg?zoom=2

Following filters are supported

  1. format = jpg | png | webp
    • output file format
    • e.g. format=jpg
  2. scale = number
    • scale the image and maintain the ratio
    • number can be between 1 to 10
  3. smartcrop = width,height,interest
    • crop the image
    • width and height divided by comma in px
    • interest can be any of these
      • entropy
      • center
      • attention
      • high
      • low
      • last
      • none
    • e.g. crop=50,50,center
  4. rotate = angle
    • rotate the image
    • allowed angles are
      • 90
      • 180
      • 270
    • e.g. rotate=90
  5. flip = h or v
    • flip the image vertically or horizontally
    • h for horizontal and v for vertical
    • e.g. flip=h or flip=v
  6. sharpen = sigma,threshold?,slope?
    • sharpen the image
    • sigma = the sigma of the Gaussian mask
    • threshols = the level of sharpening to apply to "flat" areas.
    • slope = the level of sharpening to apply to "jagged" areas.
    • e.g. sharpen=5,1.0,2.0
  7. modulate = brightness,saturation?,hue?
    • transforms the image using brightness, saturation, hue rotation
    • e.g. modulate=2,2,180
  8. label = text,font,width,height,x-location,y-location,opacity,color<r:g:b>
    • add text on top of image
    • e.g. label=hello,arial,50,40,10,10,1,185:53:53
  9. pixlate = number
    • pixlate the image
    • number can be between 1 to 100
    • e.g. pixlate=10
  10. scale = float-number
    • scale the image and maintain the ratio
    • float number can be between 0 to 10
    • e.g. scale=2.5
  11. repeat = x-number,y-number
    • x-number is number of times to repeat horizontally
    • y-number is number of times to repeat vertically
    • number can be between 1 to 10
    • e.g. repeat=5,2

To install vips on your machine

About

Image optimisation server written in golang

License:MIT License


Languages

Language:Go 100.0%