I saw python codes to join two images in google app engine with ‘composite’. But I need java codes to use ‘composite’ to merge two images. Showing an actual code would be very helpful.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is my first reply, so hopefully I won’t be hammered too badly. Since nobody else answered this, and I spent a bit of time on this today, I thought I’d provide some code.
The main reason this took way too much time for me, is that for whatever reason, the devserver simulation of the Images API doesn’t work right and the composite images are not correct when using the devserver. I was spending forever fiddling with the values in the devserver, until I just uploaded the test code to AppEngine, and it worked as expected. Argg!
Anyway, the code below assumes you have two 300×300 images, one in aImage and other in bImage, that you want to paste side-by-side into a 600×300 new canvas, which is created in the resulting Image newImage:
The first makeComposite places the first image at location 0,0 relative to TOP_LEFT. The second makeComposite places the second image at 300,0. Both are pasted with opacity 1.0. Hope this helps. This code saves the result in JPEG format. And, again, for me, this DOES NOT WORK in the devserver, but works as expected on the real App Engine platform.