使用谷歌应用引擎和python合并2个图像?

时间:2021-11-15 01:19:30

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

我想在第一张图像的特定位置合并2张图像。

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

示例:第1张图像:x.png(400 X 400px)第2张图像:y.png(100,100坐标)

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

我怎么能在google appengine中使用python来做到这一点。

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.

谢谢,请让我知道更多说明。

3 个解决方案

#1


12  

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

这可以使用非常简化的成像库来完成,该库模拟PIL的一些功能。你需要的功能是复合的

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

#2


2  

Try composite method : see the documentation

尝试复合方法:请参阅文档

#3


1  

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

您可以在google images api中查看复合模块。如果它不起作用。这也值得一试。这是在python中使用Image模块

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

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

#1


12  

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

这可以使用非常简化的成像库来完成,该库模拟PIL的一些功能。你需要的功能是复合的

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

#2


2  

Try composite method : see the documentation

尝试复合方法:请参阅文档

#3


1  

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

您可以在google images api中查看复合模块。如果它不起作用。这也值得一试。这是在python中使用Image模块

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

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