2

I have stored thousands of images in GCP Cloud Storage in very high resolution. I want to serve these images in an iOS/Android App and on a website. I don't want to serve all the time the high-resolution version and wondered whether I have to create duplicate images in different resolutions - which seems very inefficient. The perfect solution would be that I can append a parameter like ?size=100 to the image URL. Is something like that natively possible with GCP Cloud Storage?

I don't find anything in the documentation from cloud storage: https://cloud.google.com/storage/docs. Several other resources link to deprecated solutions: https://medium.com/google-cloud/uploading-resizing-and-serving-images-with-google-cloud-platform-ca9631a2c556

What is the best solution to implement such functionality?

1 Answer 1

3

Cloud Storage currently does not have Imaging services yet, though a Feature Request already exists. I highly suggest that you "+1" and "star" this issue to increase its chance to be prioritized in development.

You are right that this use case is common. Image API is a Legacy App Engine API. It's no longer a recommended solution because Legacy App Engine APIs are only available in older runtimes that have limited support. GCP would advise developers to use Client Libraries instead but since your requested feature is not yet available, then you'll have to use third-party imaging libraries.

In this case, developers are commonly using Cloud Functions with Cloud Storage Trigger, thus resizing and creating duplicate images in different resolutions. While you may find the solution inefficient, unfortunately there's not much choice but to process those images until the feature request becomes available in public.

One good thing though is that Cloud Functions supports multiple runtimes so you can write code in any supported languages and pick libraries you're comfortable using. If you're using Node runtime, feel free to check this sample that automatically creates thumbnail when an image is uploaded to Cloud Storage.

2
  • Thank you for the hint. I "starred'" the issue. The disadvantage of using Cloud Functions for doing the image optimization is imo that you have to decide upfront which sizes and formats you need. I was looking for a solution that offers me great flexibility. In the end, I ended up using "Cloudimage", which I can easily connect with my GCP Cloud Storage and which works as a CDN for my images. You can not only add parameters for size to the URL, but also filters (black/white), rotation or even add watermarks on the images. This is exactly what I was looking for and solves my case pretty good.
    – Luke
    Commented Jul 13, 2021 at 8:37
  • As a newcomer to CDN and a huge fan of Google Cloud Services in general I find Google's position on this issue surprising. Is there a reason, I wonder?
    – MartinJ
    Commented Jul 23, 2022 at 7:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.