Skip to content

Instantly share code, notes, and snippets.



Created Sep 14, 2012
What would you like to do?
Image postcard
Today is my second day of golang learning. I have gone through all the exercises of go tutorial on 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 := "/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 := "/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.

This comment has been minimized.

Copy link
Owner Author

@jvkumar jvkumar commented Sep 14, 2012 may help but I am lost as how to use it?

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