简体   繁体   中英

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

尝试composite方法: 请参阅文档

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM