Instantly share code, notes, and snippets.

# jvkumar/postcard.go

Created September 14, 2012 23:33
Show Gist options
• Save jvkumar/3725604 to your computer and use it in GitHub Desktop.
Image postcard
This file contains 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
 Today is my second day of golang learning. I have gone through all the exercises of go tutorial on http://tour.golang.org/ and I am trying to write a simple program to overlap one image on another. My goal is to have an image (called background image) and then paste two images on top of it with given x, y, and z axis value with some angle (rotation). I have skeleton of my first golang code below. I am freaking out as how to proceed. Any help or example of code will be greatly appreciated. =========================================== package main func main() { //ASSUMPTION: All images will be jpg and much smaller compare to background image and they will never go outside the background image //Background image, on which image1 and image2 shoudl be stitched //X and y axis values are 0 at the bottom left corner of thsi background image bgimage := "/a/background.jpg" //Image1 image1 := "/b/img1.jpg" //path image1_x := 12 //top left corner of image1 should be positioned at x-axis value 12 image1_y := 3 //top left corner of image 1 should be positioned at x-axis value 12 image1_z := 1 //Sometime image1 and image2 may overlap each other, so z axis defines which come in foreground image1_rotate := 22 //Rotate the image1 by 22 degree clockwise //Image2 image2 := "/b/img2.jpg" image2_x := 310 image2_y := 6 image2_z := 2 image2_rotate := -12 //(Note: minus value is for anticlockwise rotation) //I want image1 and image2 be stitched over bgimage using above geometry. and finally get the stitched image //Your help needed here ..... } ========================== Thank you in advance.

### jvkumar commented Sep 14, 2012

http://golang.org/doc/articles/image_draw.html may help but I am lost as how to use it?

to join this conversation on GitHub. Already have an account? Sign in to comment