Skip to content

Instantly share code, notes, and snippets.

@kazukgw
Created September 11, 2015 07:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kazukgw/4359ce99f09dcbd1afe6 to your computer and use it in GitHub Desktop.
Save kazukgw/4359ce99f09dcbd1afe6 to your computer and use it in GitHub Desktop.
gographics/imagick をつかってgolangで画像をresizeする
package main
import "github.com/gographics/imagick/imagick"
func main() {
imagick.Initialize()
defer imagick.Terminate()
mw := imagick.NewMagickWand()
defer mw.Destroy()
if err := mw.ReadImage("2015-09-11_15-34-51.jpg"); err != nil {
panic(err.Error())
}
w := mw.GetImageWidth()
h := mw.GetImageHeight()
if err := mw.ResizeImage(w/10, h/10, imagick.FILTER_LANCZOS, 1); err != nil {
panic(err.Error())
}
mw.WriteImage("resized.jpg")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment