Reputation: 2642
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?
Upvotes: 1
Views: 3234
Reputation: 9715
Image cropping functionality is fairly easy to implement these days. You can then do whatever you want with the image - store it back to Google Storage
or return it immediately to the client.
What's more, you can easily deploy that functionality to any cloud-based serverless solution.I was using Cloud Run
because it's Docker-based and hence can be ported anywhere potentially.
I have a service that we use for image cropping based on nodejs/sharp
and deployed into Google Cloud Run. You can use it as-is. There's nothing project-specific hardcoded in it.
Upvotes: 0
Reputation: 41099
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".
Upvotes: 1