开发者

Merge 2 images using google app engine and python?

I want to merge 2 images and that too at specific location of 1st image.

Example: 1st image: x.png (400 X 400px) 2nd image: y.png (at 100,100 co-ordinates)

How can i do this using python in google appengine.?

If you can provide开发者_开发技巧 some codes for this ... or any reference to this code... will be appreciated.

Thank you, Please let me know for more clarification.


This can be done using the very cut down imaging library which emulates some of the functions of PIL. The function you need is composite

from google.appengine.api import images

xpng = #Load data from x.png here, or read from BlobProperty
ypng = #Load data from y.png here, or read from BlobProperty

composite = images.composite([(xpng, 0, 0, 1.0, images.TOP_LEFT),
    (ypng, 100, 100, 1.0, images.TOP_LEFT)], 400, 400)

#composite now holds your new image data, to do what you want with


Try composite method : see the documentation


You can have look at the composite module in google images api.If it doesntt work . This is also worth giving a try. This is using Image module in python

import Image
image1 = Image.open("#imageurl")
iamge2 = Image.open("#imageurl")

image1.paste(image2, (0, 0), image2)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜