Image Processing with Go

Refer to my Node.js post on the same topic

package main

import (
    "github.com/disintegration/imaging"
    "image"
)

func main(){
    if img,err := imaging.Open("test.jpg"); err == nil {
        newimg := imaging.Resize(img, 300, 200, imaging.Lanczos)

        imaging.Save(newimg, "test2.jpg")

        cropped := imaging.Crop(img, image.Rect(0,0, 600, 600))

        imaging.Save(cropped, "test3.jpg")
        imaging.Save(cropped, "test3.png")

        crsz := imaging.Resize(cropped, 200, 200, imaging.Lanczos)
        imaging.Save(crsz, "test4.jpg")
    }
}

blog comments powered by Disqus