开发者

Google App Engine PIL lib TypeError: object of type 'Image' has no len()

I want to crop an image using images library of google app engine. The code part that i am using for t开发者_C百科his is the following.

                key = self.request.get("blobkey")
                img = images.Image(str(key))
                images.crop(img,0.0,0.0,0.5,0.5)
                resim = img.execute_transforms(output_encoding=images.PNG)

        content = {
        }

        self.response.headers['Content-Type'] = "image/png"
        self.response.out.write(resim)

But when i try to crop an image, it gives such an error.

                TypeError: object of type 'Image' has no len()

Is there anyone who knows about this error or is there any other way that i can crop an image in python?

Thanks in advance..


Looking at Image documentation

class Image(image_data=None, blob_key=None)

you forgot to specify the blob_key name parameter calling the Image constructor:

key = self.request.get("blobkey")
img = images.Image(blob_key = str(key)) #You should specify blob_key
images.crop(img,0.0,0.0,0.5,0.5)
resim = img.execute_transforms(output_encoding=images.PNG)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜