在Google云端存储中调整图片大小 [英] Resize image in Google Cloud Storage

查看:336
本文介绍了在Google云端存储中调整图片大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

appengine / image软件包可以正常处理存储在Blobstore中的图像。但是,如何调整存储在Google云端存储中的图像的大小?

您可以将相同的图像服务与Google云端存储,特别是如果您使用Blobstore API上传图片。



Java中的示例代码:

  String fullName =/ gs /+ bucketName +/+ objectName; 
Image picture = ImagesServiceFactory.makeImageFromFilename(fullName);
Transform resize = ImagesServiceFactory.makeResize(maxWidth,maxHeight);
picture = imagesService.applyTransform(resize,picture);

在Go中,您可以使用 BlobKeyForFile 函数:
$ b


BlobKeyForFile返回一个BlobKey用于Google存储文件。
文件名的格式应该是/ gs / bucket_name / object_name。



The appengine/image package works fine with images stored in Blobstore. However, what would be a good approach to resize images stored in Google Cloud Storage?

解决方案

You can use the same Image Service with the Google Cloud Storage, especially if you use Blobstore API for uploading images.

A sample code in Java:

String fullName = "/gs/" + bucketName + "/" + objectName;
Image picture = ImagesServiceFactory.makeImageFromFilename(fullName);
Transform resize = ImagesServiceFactory.makeResize(maxWidth, maxHeight);
picture = imagesService.applyTransform(resize, picture);

In Go, you can use BlobKeyForFile function:

BlobKeyForFile returns a BlobKey for a Google Storage file. The filename should be of the form "/gs/bucket_name/object_name".

这篇关于在Google云端存储中调整图片大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆