2011-12-17 43 views
1
def embedd_image(): 
    from google.appengine.api import images 

    img1 = images.Image('/home/ubuntu/a.png') // Here I am getting **error 
    img2 = images.Image('/home/ubuntu/text.png') // Here I am getting **error                                 
    composite = images.composite([(img1, 0, 0, 1.0, images.TOP_LEFT), (img2, 81, 25, 1.0, images.TOP_LEFT)], 144, 68, output_encoding=0)       
    return composite                                     

**錯誤是Unrecognized image format蟒蛇 - AppEngine上的圖像API錯誤

+0

您將無法訪問應用程序的根目錄以外的文件在App Engine上 - 畢竟,怎麼會在部署應用程序訪問你的home目錄?另外,當您發佈這些問題時,請包含完整的異常堆棧跟蹤,而不僅僅是錯誤的解釋。 – 2011-12-19 05:52:58

回答

2

docs

class Image(image_data=None, blob_key=None)

...

image_data的圖像數據,作爲字節串(str)。數據可以用JPEG,PNG,WEBP,GIF(包括動畫),BMP, TIFF或ICO格式編碼。

爲一個字節字符串:

img1 = images.Image(open('/home/ubuntu/a.png').read())