duanmao7553 2014-04-30 00:39
浏览 191

调整Google Cloud Storage中的图片大小

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?

  • 写回答

1条回答 默认 最新

  • douhui2307 2014-04-30 00:46
    关注

    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".

    评论

报告相同问题?