How to save a rotated image which was stored in GA

2019-09-13 03:28发布

I want to rotate and save an image which was already stored in blobstore. For this I tried using images.Image.rotate method

img = images.Image(blob_key=image.blob)
img.rotate(180)
final_image = img.execute_transforms(output_encoding=images.PNG)

I don't know how to save the rotated image again to the blobstore.

2条回答
贼婆χ
2楼-- · 2019-09-13 03:51

Writing to the blobstore used to be possible using the Files API, which is now deprecated.

You can use GCS instead for writing the image (GCS is recommended over Blobstore anyways).

You can still keep the blobstore API with GCS if you want. I think it should be possible to even mix blobstore and GCS transparently for your users so that you don't have to migrate all your existing images from the blobstore to GCS.

查看更多
男人必须洒脱
3楼-- · 2019-09-13 04:10

A transformed image is just a collection of bytes that you can write back to the Cloud Storage - as a new object or overwrite an existing one (e.g. cloudstorage.open with mode set to "w" using Python GS Client).

查看更多
登录 后发表回答