Firebase once again released a new addition to their multitude of tools and services and this tool is, well, A LOT of tools in one. In a package they call Firebase Extensions, we have access to a number of automated tasks that we can install directly from Firebase instead of having to invest time and costs in writing them ourselves. These extensions include things like text translation, resizing images uploaded to Cloud Storage, sending emails when data is added to Cloud Firestore, URL shortening, Mailchimp syncing, yeah there’s quite a few.

A few of the Firebase Extensions found on the official page

Firebase Extensions can be configured through either the Firebase Console or the Firebase CLI. Since it’s so easy to do in the Console, we’ll start with that.

We’re going to learn how to use them through the Resize Images extension as it’s one of the easier ones to get started with.

Install the Dependencies

If you haven’t already, connect your app to Firebase, then add these dependencies to your  app/build.gradle file.

Just like most extensions, this one makes use of other Firebase services. The Resize Image extension uses Cloud Storage to, well, upload the image to storage and Cloud Functions to perform the resizing on the cloud.

Extensions however doesn’t need to add itself as a dependency in your app as it works exclusively on the cloud.

Configure the Firebase Extension

Head into the Firebase Console and on the left side bar, click on Extensions. Look for the Resize Images extension, and follow the process to get it set up.

I chose to left most of the parameters default as they suffice. There’s also a parameter that lets you specify in which path of the Cloud Storage you want this extension to apply to. Leaving it blank makes it apply to the whole bucket, which I did as I wasn’t too concerned with resizing images in only a certain path.

Eitherway, the extension will trigger automatically and upon finishing the resize, it will save both the original and the resized image into your specified path.

So once you finish setting up your extension, it’ll take a few minutes to get loaded. Once it is, then it’s ready to do it’s job!

Set up Cloud Storage

All that’s left is for us to actually upload an image from within our app.

My layout consists of just a single button. All of the code here in my MainActivity just uses that button to upload an image to Cloud Storage. If you’re new to Firebase Cloud Storage, you’ll find my tutorial on it pretty helpful.

We’re all done! Trigger the upload from within in the app by SMASHING that upload button we created and SLAPPING an image onto it and in no time, we’ll see that image along with a resized version of it in Cloud Storage where we specified our path.

That’s all for now. Happy Coding (づ。◕‿‿◕。)づ