Created
February 22, 2017 00:44
-
-
Save hackintoshrao/45a0527803a3c843a55e861cb94fdcb2 to your computer and use it in GitHub Desktop.
Thubnail generator for golang.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "image" | |
| "image/color" | |
| "github.com/disintegration/imaging" | |
| ) | |
| func main() { | |
| // input files | |
| file := "1.jpg" | |
| // load images and make 100x100 thumbnails of them | |
| var thumbnail image.Image | |
| img, err := imaging.Open(file) | |
| if err != nil { | |
| panic(err) | |
| } | |
| thumbnail = imaging.Thumbnail(img, 100, 100, imaging.CatmullRom) | |
| // create a new blank image | |
| dst := imaging.New(100, 100, color.NRGBA{0, 0, 0, 0}) | |
| // paste thumbnails into the new image side by side | |
| dst = imaging.Paste(dst, thumbnail, image.Pt(0, 0)) | |
| // save the combined image to file | |
| err = imaging.Save(dst, "dst.jpg") | |
| if err != nil { | |
| panic(err) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment