Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在GAE中将Image.ANTIALIAS与resize()一起使用?_Python_Image_Google App Engine - Fatal编程技术网

Python 如何在GAE中将Image.ANTIALIAS与resize()一起使用?

Python 如何在GAE中将Image.ANTIALIAS与resize()一起使用?,python,image,google-app-engine,Python,Image,Google App Engine,我正在使用下面的脚本调整图像大小。但我注意到,调整大小后的图像失去了清晰度图像。ANTIALIAS是最佳的“缩小过滤器”。但是当我在代码中添加过滤器时 images.resize(homepage.original_image, 200, 200, Image.ANTIALIAS) 我明白了 有办法解决这个问题吗?谢谢 class ImageResize(webapp.RequestHandler): def get(self): q = HomePage.all()

我正在使用下面的脚本调整图像大小。但我注意到,调整大小后的图像失去了清晰度<代码>图像。ANTIALIAS是最佳的“缩小过滤器”。但是当我在代码中添加过滤器时

images.resize(homepage.original_image, 200, 200, Image.ANTIALIAS)
我明白了

有办法解决这个问题吗?谢谢

class ImageResize(webapp.RequestHandler):
    def get(self):
        q = HomePage.all()
        result = q.fetch(3)
        for item in result:
            firm = item.firm_name
            id = item.key().id()
            if id:
                homepage = HomePage.get_by_id(id)
                if homepage:
                    thumbnail =    images.resize(homepage.original_image, 200, 200)
                    homepage.thumbnail = db.Blob(thumbnail)
                    homepage.put()

您链接的文档是针对PIL的,但您使用的是Google App Engine
images
API,其文档位于此处:

@Mark Ransom:谢谢!我将代码更改为:
thumboil=images.resize(homepage.original\u image,300300,images.JPEG,100)
。由于某种原因,
quality
参数的位置没有指明,所以我把它放在末尾;SDK不支持它,所以我还不知道这是否有效。再次感谢。@Zeynel质量参数指定JPEG质量参数(例如,图像的压缩程度);设置得越高,图像越大、越清晰,但请注意不要设置得太高,因为这只会在某个阈值上浪费空间。@尼克:我试图使用类似于PIL中的
size
的函数来获取图像的大小,但在images API中找不到它。你知道我怎样才能得到图像的大小吗?我使用的是上面提到的100,图像看起来不错。@Zeynel,请尝试
宽度
高度
属性。
class ImageResize(webapp.RequestHandler):
    def get(self):
        q = HomePage.all()
        result = q.fetch(3)
        for item in result:
            firm = item.firm_name
            id = item.key().id()
            if id:
                homepage = HomePage.get_by_id(id)
                if homepage:
                    thumbnail =    images.resize(homepage.original_image, 200, 200)
                    homepage.thumbnail = db.Blob(thumbnail)
                    homepage.put()