为什么 Appengine 图像旋转会出现缓存资源错误?
Why does Appengine image rotation give cache resources error?
我使用 Appengine 标准:
basic_scaling:
max_instances: 7
idle_timeout: 4m
instance_class: B4_1G
我尝试旋转图像:
def get_image(bucket_name, file_name):
blob = storage_client.bucket(bucket_name).get_blob(file_name)
_, temp_local_filename = tempfile.mkstemp()
blob.download_to_filename(temp_local_filename)
with Image(filename=temp_local_filename) as i:
encoded_image = base64.b64encode(open(i.rotate(125), 'rb').read())
del i
gc.collect()
return (html.Img(src='data:image/png;base64,{}'.format(encoded_image.decode('utf-8')), style={'height':'400%', 'width':'100%'}))
但我得到:
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/wand/resource.py", line 222, in raise_exception
raise e
wand.exceptions.CacheError: cache resources exhausted `/tmp/tmp0gu_437j' @ error/cache.c/OpenPixelCache/3984
在旋转线上。
i.rotate(125)
给出错误,但是
i.rotate(90)
和 270 一样有效。我只需要旋转 90 度就可以了。
我使用 Appengine 标准:
basic_scaling:
max_instances: 7
idle_timeout: 4m
instance_class: B4_1G
我尝试旋转图像:
def get_image(bucket_name, file_name):
blob = storage_client.bucket(bucket_name).get_blob(file_name)
_, temp_local_filename = tempfile.mkstemp()
blob.download_to_filename(temp_local_filename)
with Image(filename=temp_local_filename) as i:
encoded_image = base64.b64encode(open(i.rotate(125), 'rb').read())
del i
gc.collect()
return (html.Img(src='data:image/png;base64,{}'.format(encoded_image.decode('utf-8')), style={'height':'400%', 'width':'100%'}))
但我得到:
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/wand/resource.py", line 222, in raise_exception
raise e
wand.exceptions.CacheError: cache resources exhausted `/tmp/tmp0gu_437j' @ error/cache.c/OpenPixelCache/3984
在旋转线上。
i.rotate(125)
给出错误,但是
i.rotate(90)
和 270 一样有效。我只需要旋转 90 度就可以了。