Is there an efficient method to serve dynamic size images stored in firebase storage through changing Query parameter in image URL? Or something like Imgix? what is the most efficient method?
-
https://cloud.google.com/appengine/docs/standard/php/googlestorage/images – Doug Stevenson Aug 20 '17 at 15:46
2 Answers
I recommend You try this Cloud Functions for Firebase Storage resizing using ImageMagick
Writing a Cloud Storage Trigger with Cloud Functions for Firebase
sample code

- 1,772
- 1
- 15
- 29
-
2
-
https://www.quora.com/Is-it-possible-to-download-a-low-resolution-image-previously-uploaded-in-HD-from-Firebase-Storage-while-indicating-specific-height-and-width it's available now ? – LOG_TAG Jun 12 '19 at 17:53
-
I use the following technique on my firebase project to do just what you are asking. Google cloud has a dynamic imageURL you can get that serves up image sizes based on the url parameter.
You'll have to call the getImageServingUrl
method on the image after it's been uploaded - this will give you the dynamic image serving url you can then use. So, in addition to your firebase project, you'll have to set up a google cloud project to host the service that will generate the serving URL for an image.
Below is a GO example of an endpoint you can hit after the file is uploaded to get the dynamic image url.
import (
"fmt"
"net/http"
"google.golang.org/appengine"
"google.golang.org/appengine/image"
"google.golang.org/appengine/blobstore"
)
func init() {
http.HandleFunc("/photo", photoHandler)
}
func photoHandler(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
v := r.URL.Query()
fileName := v.Get("file")
if (fileName == "") {
fmt.Fprint(w, "file name is required")
} else {
filename := "/gs/" + fileName;
blobKey,err := blobstore.BlobKeyForFile(c, filename)
if (err == nil) {
url, urlErr := image.ServingURL(c, blobKey, nil)
if (urlErr == nil) {
fmt.Fprint(w, url)
} else {
fmt.Fprint(w, urlErr)
}
} else {
fmt.Fprint(w, "image does not exist")
}
}
}

- 46,433
- 78
- 254
- 460
-
Your proposed solution has been deprecated and disabled :/ - any idea, what could be used as a replacement? – wiesson Aug 22 '20 at 14:28