An image server toolkit in Go (Golang)

Image Server

An image server toolkit in Go (Golang)

GoDoc Build Status Go Report Card

Features

Examples

Demos

These demos use the "advanced" example.

Click the images to see the URL parameters.

Resize

Options Result
width=200
(preserve aspect ratio)
height=200
(preserve aspect ratio)
width=200&height=200
(change aspect ratio)
width=200&height=200&mode=fit
(fit in 200x200)
width=200&height=200&mode=fill
(fill 200x200 and crop)

Rotate

Options Result
rotation=90
(counterclockwise)
rotation=45&background=ffaa88
(background)

Crop

Format: min_x,min_y|max_x,max_y

Options Result
crop=556,111|2156,1711
crop=956,511|1756,1311
crop=1252,799|1460,1022

Animated GIF

Original Resized
Animated
Spaceship

Gamma correction (more info)

Original Disabled Enabled
Dalai Gamma
Gray squares
Random
Rings
Rules / sucks

Resampling

Resampling Rings Large
Nearest neighbor
Box
Linear
Cubic
Lanczos

Quality

JPEG quality Result
5%
10%
50%

Convert (JPEG to GIF)

Backward compatibility

There is no backward compatibility promises. If you want to use it, vendor it. It's always OK to change things to make things better. The API is not 100% correct in the first commit.

Owner
Pierre Durand
¯\_(ツ)_/¯
Pierre Durand
Comments
  • add more params and functionalities taking advantage of GraphicsMagick

    add more params and functionalities taking advantage of GraphicsMagick

    The added params are:

    • gravity: "-gravity" param, default is Center
    • crop: "-crop" param with "+repage"
    • rotate: "-rotate" param
    • monochrome: "-monochrome" param
    • grey: "-colorspace" param with "GRAY"
    • no_strip: "-strip" param
    • trim: "-trim" param
    • no_interlace: "-interlace" param with "Line". Useful for JPEG, I'm not sure about other formats.
    • flip: "-flip" param
    • flop: "-flop" param Please go to GraphicsMagick documentation for detailed explanation.

    Added test functions for buildArguments.

    Params parser now divided into 3 main parts to parse int, bool and string type params. Adding params is easier this way.

  • Strange cache implementation

    Strange cache implementation

    When we use cache (memory, redis, both of them), and run GOMAXPROCS=2, we see next:

    1. 50 request per second
    2. 8 core 100% loading

    Then, we turn off cache and see:

    1. 8000 request per second
    2. 8 core 50% loading

    ???

  • Add disk based cache system

    Add disk based cache system

    I added the package "cache/file" that support a disk based cache system. With low memory environment the disk based cache system is useful.

    Usage (part of examples/cache):

    var flagFile     = "/tmp"
    
    // part of examples/cache/cache.go
    func newServerFile(srv imageserver.Server) imageserver.Server {
    	if flagFile == "" {
    		return srv
    	}
    	cch := imageserver_cache_file.Cache{flagFile }
    	kg := imageserver_cache.NewParamsHashKeyGenerator(sha256.New)
    	return &imageserver_cache.Server{
    		Server:       srv,
    		Cache:        &cch,
    		KeyGenerator: kg,
    	}
    }
    
  • Hotlink image to cache ?

    Hotlink image to cache ?

    Hello there, nice server !

    Would that be possible to hotlink images to cache ?

    Something like

    http://fuckingfrogs.fr:8080/?source=http://stock.wikimini.org/w/images/b/b5/Poney_shetland-9380.jpg
    

    that would make the server download the image only on the first hit and then cache it ?

    Cheers !

  • Help deploying to App Engine

    Help deploying to App Engine

    Hi Pierrre,

    I would like some help deploying a golang image server using your package to the Google App Engine.

    Problem is, App Engine rejects the use of sockets. I think in order to rectify the issue, "google.golang.org/appengine/socket" package is necessary.

    I'm trying to follow this github issue to fix the issue: https://github.com/go-sql-driver/mysql/issues/457

    "google.golang.org/appengine"
    "github.com/go-sql-driver/mysql"
    "google.golang.org/appengine/socket"
    
    dial := func(addr string) (net.Conn, error) {
            return socket.Dial(appengine.NewContext(r), "tcp", addr)
        }
    
    mysql.RegisterDial("external", dial)
    

    However, I'm not sure how I could get access to the http request from where the Redis socket.Dial() is called.

  • Is it possible to load images from a custom folder.

    Is it possible to load images from a custom folder.

    Hi, the project is awesome and I like it very much. I want to use it as my image server, however, I found all the images are loaded from a special folder naming testdata. I am wondering How can I custom some codes to make it possible that I can totally use the project as an image server including getting images from a custom folder on my disk.

  • about time.LoadLocation(

    about time.LoadLocation("GMT") in windows server2012 problem

    in Windows Server 2012 Failure to perform normally time.LoadLocation("GMT")

    The error is as follows:

    UTC open C:\Go/lib/time/zoneinfo.zip: The system cannot find the path specified.
    

    And I found your questions at go's issues,But our system is different

    I found in the test that the program can be used normally by modifying imageserver/http/util.go/GMT to UTC. Therefore, if the GMT in the source code is changed to UTC, is this correct? I hope to get your suggestion?

    //src
    // var expiresHeaderLocation = getTimeLocation("GMT")
    //me code
    var expiresHeaderLocation = getTimeLocation("UTC")
    
  • internal server error

    internal server error

    Hi! Thanks for this repo, I'm trying to learn Go so maybe it's my fault but I'm struggling with an error.

    I cloned the repo in the folder where I have Go projects and I can run: go run simple.go and this is working: http://localhost:8080/?source=https://www.google.co.uk/images/srpr/logo11w.png

    But if I try to add a parameter: http://localhost:8080/?source=https://www.google.co.uk/images/srpr/logo11w.png&width=200

    I receive Internal Server Error

    How can I debug this?

    Go 1.3 on OSX 10.9.4

    Many thanks

  • unexpected directory layout

    unexpected directory layout

    System Info

    • OS: Windows10
    • Go version: go1.10.1 windows/amd64
    • GOPATH: C:\projects
    • GOROOT: C:\Go\
    • DEP: dep
    • PROJECT NAME: image

    Expected Bahavior

    Server started

    Actual Behavior

    unexpected directory layout: import path: github.com/pierrre/imageserver root: C:\projects\src dir: C:\projects\src\image\vendor\github.com\pierrre\imageserver expand root: C:\projects\src expand dir: C:\projects\src\image\vendor\github.com\pierrre\imageserver separator: \

    Description

    I tried your demo https://github.com/pierrre/imageserver/blob/master/examples/simple/simple.go with dep instead of go get, and this error happend when I tried to testrun.

    This only happens when I use dep, and imageserver is under vendor folder. It works when I use go get, but I don't see why it doesn't work anymore when I use dep.

  • Question about file cache

    Question about file cache

    When I use the file cache option, IF my instance runs out of space, what will hapepn? Does your server automatically delete files to free up disk space?

  • How to run advanced demo

    How to run advanced demo

    when i use advanced demo to run is ok, but browse the url like localhost:8080/image/1.jpg the result is : invalid param "path": unknown image "image/1.jpg" so,please tell me how to use advanced demo if i want to use graphicsmagick,how to use thank you!

  • Implements an HMAC URL signer and verifier with optional time-base expiration

    Implements an HMAC URL signer and verifier with optional time-base expiration

    hmac.Signer is an http.Handler that will sign the rest of the URI and parameters, redirecting to the signed URI to prime the cache. So signing request http://localhost:8081/_sign/food/20200723_0017_01.jpg?quality=10 redirects to http://localhost:8081/QfuWvArP9zsFRKwSJuG2MJz4DZsZe2NoVUmy7WBAwaw/food/20200723_0017_01.jpg?expiration=1669988210032&quality=10 (note the hash component and the appended expiration parameter). If any parameters are changed, the hash verification will fail. If the expiration (milliseconds from UNIX epoch) expires, the verification will fail. I can provide a full example if desirable. Happy to iterate on this for a while too if there is feedback.

    It can be wired into the groupcache example ala:

    func startHTTPServer() {
    	http.Handle("/", http.StripPrefix("/", newImageHTTPHandler()))
    	if hmacKey != "" {
    		hs := hmac.NewSigner([]byte(hmacKey), hmacDuration)
    		http.Handle("/_sign/", http.StripPrefix("/_sign/", hs))
    	}
    	http.Handle("/favicon.ico", http.NotFoundHandler())
    	initGroupcacheHTTPPool() // it automatically registers itself to "/_groupcache"
    	http.HandleFunc("/stats", groupcacheStatsHTTPHandler)
    	err := http.ListenAndServe(flagHTTP, nil)
    	if err != nil {
    		panic(err)
    	}
    }
    

    hmac.Parser is a Parser to allow "expiration" to be a valid parameter.

    func newImageHTTPHandler() http.Handler {
    	return &imageserver_http.Handler{
    		Parser: imageserver_http.ListParser([]imageserver_http.Parser{
    			&imageserver_http.SourcePathParser{},
    			&imageserver_http_crop.Parser{},
    			&imageserver_http_gift.RotateParser{},
    			&imageserver_http_gift.ResizeParser{},
    			&imageserver_http_image.FormatParser{},
    			&imageserver_http_image.QualityParser{},
    			&hmac.Parser{},
    		}),
    		Server: newServer(),
    	}
    }
    

    hmac.Verifier is an imageserver.Server that should be first (aka last) in a composition tree.

    func newServer() imageserver.Server {
    	srv = newServerImage(srv)
    	srv = newServerGroupcache(srv)
    	if hmacKey != "" {
    		srv = hmac.NewVerifier(srv, hmacKey, hmacDuration)
    	}
    	return srv
    }
    
  • Implements an S3 source.

    Implements an S3 source.

    The S3 credentials can be provided directly or in the environment. Fully composable and works excellently with the groupcache implementation. Admittedly plays loose with contexts. Resolves #26

    In the groupcache example, swapping out testdata and updating newServer() , while taking a new CLI argument for awsS3bucket works perfectly. If the S3 path would be s3://somebucket/food/20200809_0030_01.jpg then http://localhost:8081/food/20200809_0030_01.jpg?&width=1024 would be example path. I can provide a full example if desirable. Happy to iterate on this for a while too if there is feedback.

    func newServer() imageserver.Server {
    	srv, err := s3.NewS3Server(awsRegion, awsAccessKey, awsSecretKey, awsS3bucket)
    	if err != nil {
    		panic(err)
    	}
    	srv = newServerImage(srv)
    	srv = newServerGroupcache(srv)
    	return srv
    }
    
  • AWS S3 support

    AWS S3 support

    First off, kudos for the awesome work.

    Is there a way to use this with S3 bucket ? Something like a CDN server.

    Example flow:

    1. When user goes to:

    http://localhost/path/to/s3/file.jpg?width=100&height=200

    1. The server then downloads the file from S3, applies the given transformations and outputs the final image's buffer in response.
  • Newbie Scaling problem/question

    Newbie Scaling problem/question

    Hi Pierrre,

    I'm a golang/devops newbie.

    I have a Node JS web-application and chatbot that uses this repository as the golang image server to handle all the images processing (with file cache system).

    The image server is deployed in 2 instances and load balanced.

    I predict that my current setup serves/handles about ......... 500,000 to 1,000,000 images/requests per day in various sizes ... Hard to tell what the number is exactly.

    About 3 weeks ago, I noticed that a lot of my images were loading extremely slow and turning up broken. At that point I upgraded both my instances from micro to 1 vCPU, 3.75 GB mem. That actually solved the problem easily.

    Fast forward to now, I'm starting to notice some slow loading images again and saw the broken images issue once or twice only.

    Could I please get some advice and tips from you for dev-ops and scaling?

    I have never really had to handle scaling before and I'm not sure how and what data to look at to measure if my instances' resources are sufficient.

    For example, this may sound really dumb but when I look at the monitoring section in Google Cloud Platform, the CPU only peaks at 3% to 4% max, and I'm unsure if I'm looking at the right numbers.

    Thank you kindly in advance.

Image processing library and rendering toolkit for Go.

blend Image processing library and rendering toolkit for Go. (WIP) Installation: This library is compatible with Go1. go get github.com/phrozen/blend

Nov 11, 2022
Go Image Filtering Toolkit
Go Image Filtering Toolkit

GO IMAGE FILTERING TOOLKIT (GIFT) Package gift provides a set of useful image processing filters. Pure Go. No external dependencies outside of the Go

Dec 23, 2022
darkroom - An image proxy with changeable storage backends and image processing engines with focus on speed and resiliency.
darkroom - An image proxy with changeable storage backends and image processing engines with focus on speed and resiliency.

Darkroom - Yet Another Image Proxy Introduction Darkroom combines the storage backend and the image processor and acts as an Image Proxy on your image

Dec 6, 2022
Easily customizable Social image (or Open graph image) generator

fancycard Easily customizable Social image (or Open graph image) generator Built with Go, Gin, GoQuery and Chromedp Build & Run Simply, Clone this rep

Jan 14, 2022
An API which allows you to upload an image and responds with the same image, stripped of EXIF data

strip-metadata This is an API which allows you to upload an image and responds with the same image, stripped of EXIF data. How to run You need to have

Nov 25, 2021
Imgpreview - Tiny image previews for HTML while the original image is loading
Imgpreview - Tiny image previews for HTML while the original image is loading

imgpreview This is a Go program that generates tiny blurry previews for images t

May 22, 2022
Storage and image processing server written in Go
Storage and image processing server written in Go

Mort An S3-compatible image processing server written in Go. Still in active development. Features HTTP server Resize, Rotate, SmartCrop Convert (JPEG

Jan 7, 2023
An image resizing server written in Go
An image resizing server written in Go

picfit picfit is a reusable Go server to manipulate images (resize, thumbnail, etc.). It will act as a proxy on your storage engine and will be served

Dec 24, 2022
gui toolkit for go

Simple GUI toolkit with go Install You will need to install gtk-dev files. go get github.com/zozor/hgui The idea This is a gui toolkit that relies on

Feb 14, 2021
Pure golang image resizing
Pure golang image resizing

This package is no longer being updated! Please look for alternatives if that bothers you. Resize Image resizing for the Go programming language with

Jan 9, 2023
:triangular_ruler: Create beautiful generative image patterns from a string in golang.
:triangular_ruler: Create beautiful generative image patterns from a string in golang.

geopattern Create beautiful generative image patterns from a string in golang. Go port of Jason Long's awesome GeoPattern library. Read geopattern's d

Dec 29, 2022
golang package to find the K most dominant/prominent colors in an image
golang package to find the K most dominant/prominent colors in an image

prominentcolor Find the K most dominant colors in an image The Kmeans function returns the K most dominant colors in the image, ordered in the order o

Nov 7, 2022
Use Windows API to capture a image from a Webcam in GoLANG

Windows-API-Capture-Webcam Use Windows API to capture a image from a Webcam in GoLANG Other Go is a amazing and powerful programming language. If you

Aug 13, 2022
ColorX is a library to determine the most prominent color in an image written in golang

ColorX is a library to determine the most prominent color in an image. ColorX doesn't use any sort of complex algorithms to calculate the prominent color, it simply loops over the image pixels and returns the color that occurs the most.

Nov 11, 2021
Image processing algorithms in pure Go
Image processing algorithms in pure Go

bild A collection of parallel image processing algorithms in pure Go. The aim of this project is simplicity in use and development over absolute high

Jan 6, 2023
Go package for fast high-level image processing powered by libvips C library

bimg Small Go package for fast high-level image processing using libvips via C bindings, providing a simple programmatic API. bimg was designed to be

Jan 2, 2023
Decode embedded EXIF meta data from image files.

goexif Provides decoding of basic exif and tiff encoded data. Still in alpha - no guarantees. Suggestions and pull requests are welcome. Functionality

Dec 17, 2022
A lightning fast image processing and resizing library for Go

govips A lightning fast image processing and resizing library for Go This package wraps the core functionality of libvips image processing library by

Jan 8, 2023
Fast, simple, scalable, Docker-ready HTTP microservice for high-level image processing

imaginary Fast HTTP microservice written in Go for high-level image processing backed by bimg and libvips. imaginary can be used as private or public

Jan 3, 2023