GAE(AppEngine)在发布时似乎会调整图像大小 [英] GAE (AppEngine) appears to resize my image upon posting
问题描述
我已使用以下代码成功将图像发布到我的Google AppEngine应用程序中:
I am successfully posting an image to my Google AppEngine application using the following code:
def post(self):
image_data = self.request.get('file')
file_name = files.blobstore.create(mime_type='image/png')
# Open the file and write to it
with files.open(file_name, 'a', exclusive_lock=True) as f:
f.write(image_data)
# Finalize the file. Do this before attempting to read it.
files.finalize(file_name)
# Get the file's blob key
blob_key = files.blobstore.get_blob_key(file_name)
self.response.out.write(images.get_serving_url( blob_key ))
但是,当我浏览 get_serving_url()
输出的URL时,图像总是且分辨率降低.为什么??我已经检查并再次检查发布的图像尺寸是否正确(来自iPhone相机,分辨率约为3200x2400).但是,投放的图片始终为512x384.
However, when I browse the the URL outputted by get_serving_url()
, the image is always at a reduced resolution. Why? I've checked and double checked that the image being posted is of the correct size (from an iPhone camera, so approx 3200x2400 resolution). Yet, the served image is always 512x384.
我对GAE还是很陌生,但是我认为上面的代码应该将图像存储在BlobStore中而不是数据存储中,从而避免了1 MB的限制.
I'm fairly new to GAE, but I thought that the code above should store the image in the BlobStore rather than the datastore, circumventing the 1 MB limit.
有人知道会发生什么吗?
干杯,布雷特(Brett)
Cheers, Brett
推荐答案
找到了解决方案.或至少对我有用.我将 = sXX
附加到所提供网址的末尾,AppEngine将以 XX
分辨率提供图片.例如,如果该行:
Found a solution. Or at least something that works for me.
My appending =sXX
onto the end of the served URL, AppEngine will serve the image at the XX
resolution. For instance, if the line:
self.response.out.write(images.get_serving_url(blob_key))
返回: http://appengine.sample.com/appengineurlkey
然后在结果上方调用url时,该图片将是较低分辨率的图片,
Then when calling the url above results, the image will be a lower resolution image,
然后通过调用URL: http://appengine.sample.com/appengineurlkey**=s1600**
Then by calling the URL:
http://appengine.sample.com/appengineurlkey**=s1600**
最终的投放图片将采用 1600x1200
分辨率(或通过保持宽高比限制的类似分辨率).
the resulting served image will be at 1600x1200
resolution (or a similar resolution restricted by maintaining the aspect ratio).
这篇关于GAE(AppEngine)在发布时似乎会调整图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!