GithubHelp home page GithubHelp logo

gift's Introduction

GO IMAGE FILTERING TOOLKIT (GIFT)

Package gift provides a set of useful image processing filters.

Pure Go. No external dependencies outside of the Go standard library.

INSTALLATION / UPDATING

go get -u github.com/disintegration/gift

DOCUMENTATION

http://godoc.org/github.com/disintegration/gift

QUICK START

// 1. Create a new GIFT and add some filters:
g := gift.New(
    gift.Resize(800, 0, gift.LanczosResampling),
    gift.UnsharpMask(1.0, 1.0, 0.0),
)

// 2. Create a new image of the corresponding size.
// dst is a new target image, src is the original image
dst := image.NewRGBA(g.Bounds(src.Bounds()))

// 3. Use Draw func to apply the filters to src and store the result in dst:
g.Draw(dst, src)

SUPPORTED FILTERS

  • Transformations

    • Crop(rect image.Rectangle)
    • FlipHorizontal()
    • FlipVertical()
    • Resize(width, height int, resampling Resampling)
    • Rotate(angle float32, backgroundColor color.Color, interpolation Interpolation)
    • Rotate180()
    • Rotate270()
    • Rotate90()
    • Transpose()
    • Transverse()
  • Adjustments & effects

    • Brightness(percentage float32)
    • ColorBalance(percentageRed, percentageGreen, percentageBlue float32)
    • Colorize(hue, saturation, percentage float32)
    • ColorspaceLinearToSRGB()
    • ColorspaceSRGBToLinear()
    • Contrast(percentage float32)
    • Convolution(kernel []float32, normalize, alpha, abs bool, delta float32)
    • Gamma(gamma float32)
    • GaussianBlur(sigma float32)
    • Grayscale()
    • Hue(shift float32)
    • Invert()
    • Maximum(ksize int, disk bool)
    • Mean(ksize int, disk bool)
    • Median(ksize int, disk bool)
    • Minimum(ksize int, disk bool)
    • Saturation(percentage float32)
    • Sepia(percentage float32)
    • Sigmoid(midpoint, factor float32)
    • UnsharpMask(sigma, amount, thresold float32)

FILTER EXAMPLES

Resize using lanczos resampling
gift.Resize(200, 0, gift.LanczosResampling)
Original image Filtered image
original filtered
Resize using linear resampling
gift.Resize(200, 0, gift.LinearResampling)
Original image Filtered image
original filtered
Crop 90, 90 - 250, 250
gift.Crop(image.Rect(90, 90, 250, 250))
Original image Filtered image
original filtered
Rotate 90 degrees
gift.Rotate90()
Original image Filtered image
original filtered
Rotate 180 degrees
gift.Rotate180()
Original image Filtered image
original filtered
Rotate 270 degrees
gift.Rotate270()
Original image Filtered image
original filtered
Rotate 30 degrees, white background, cubic interpolation
gift.Rotate(30, color.White, gift.CubicInterpolation)
Original image Filtered image
original filtered
Flip horizontal
gift.FlipHorizontal()
Original image Filtered image
original filtered
Flip vertical
gift.FlipVertical()
Original image Filtered image
original filtered
Transpose
gift.Transpose()
Original image Filtered image
original filtered
Transverse
gift.Transverse()
Original image Filtered image
original filtered
Contrast +30%
gift.Contrast(30)
Original image Filtered image
original filtered
Contrast -30%
gift.Contrast(-30)
Original image Filtered image
original filtered
Brightness +30%
gift.Brightness(30)
Original image Filtered image
original filtered
Brightness -30%
gift.Brightness(-30)
Original image Filtered image
original filtered
Saturation +50%
gift.Saturation(50)
Original image Filtered image
original filtered
Saturation -50%
gift.Saturation(-50)
Original image Filtered image
original filtered
Hue +45
gift.Hue(45)
Original image Filtered image
original filtered
Hue -45
gift.Hue(-45)
Original image Filtered image
original filtered
Sigmoid 0.5, 5.0
gift.Sigmoid(0.5, 5.0)
Original image Filtered image
original filtered
Gamma correction = 0.5
gift.Gamma(0.5)
Original image Filtered image
original filtered
Gamma correction = 1.5
gift.Gamma(1.5)
Original image Filtered image
original filtered
Gaussian blur, sigma=1.0
gift.GaussianBlur(1.0)
Original image Filtered image
original filtered
Unsharp mask, sigma=1.0, amount=1.5, thresold=0.0
gift.UnsharpMask(1.0, 1.5, 0.0)
Original image Filtered image
original filtered
Grayscale
gift.Grayscale()
Original image Filtered image
original filtered
Sepia, 100%
gift.Sepia(100)
Original image Filtered image
original filtered
Invert
gift.Invert()
Original image Filtered image
original filtered
Colorize, blue, saturation=100%
gift.Colorize(240, 100, 100)
Original image Filtered image
original filtered
Color balance, +20% red, -20% green
gift.ColorBalance(20, -20, 0)
Original image Filtered image
original filtered
Local mean, disc shape, size=5
gift.Mean(5, true)
Original image Filtered image
original filtered
Local median, disc shape, size=5
gift.Median(5, true)
Original image Filtered image
original filtered
Local minimum, disc shape, size=5
gift.Minimum(5, true)
Original image Filtered image
original filtered
Local maximum, disc shape, size=5
gift.Maximum(5, true)
Original image Filtered image
original filtered
Convolution matrix - Emboss
gift.Convolution(
    []float32{
        -1, -1, 0,
        -1, 1, 1,
        0, 1, 1,
    },
    false, false, false, 0.0,
)
Original image Filtered image
original filtered
Convolution matrix - Edge detection
gift.Convolution(
    []float32{
        -1, -1, -1,
        -1, 8, -1,
        -1, -1, -1,
    },
    false, false, false, 0.0,
)
Original image Filtered image
original filtered

gift's People

Contributors

disintegration avatar nixterrimus avatar

Watchers

 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.