Pull request Compare This branch is 6 commits ahead, 143 commits behind Node-8.
nicolasgarnier Upgrade all firebase-admin imports to 5.11.0
Change-Id: Ib3f6a5f57d3fdd0dbc2ee3d27efbd3cf00966257
Latest commit 849ab0b Mar 26, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
functions Upgrade all firebase-admin imports to 5.11.0 Apr 3, 2018
README.md Readme tweaks Oct 6, 2017
firebase.json Image-sharp sample added Jun 29, 2017


Image resizing using Node.js Stream and Sharp - Cloud Storage trigger

This sample demonstrates how to use Node.js Stream to read image from Cloud Storage, generate a thumbnail image using Sharp and upload it back to Cloud Storage. This is a alternative approach for using ImageMagick, see generate-thumbnail.

Functions Code

See file functions/index.js for the thumbnail generation code.

The thumbnail generation is performed using Sharp. Download, resize input/output and upload uses Node.js Stream

The dependencies are listed in functions/package.json.

Trigger rules

The function triggers on upload of any file to your Firebase project's default Cloud Storage bucket.

Deploy and test

To deploy and test the sample:

  1. Create a Firebase project on the Firebase Console.
  2. Get the code, for instance using git clone https://github.com/firebase/functions-samples
  3. Enter the correct directory cd functions-samples/image-sharp
  4. If you do not have it yet, install the Firebase CLI npm install -g firebase-tools
  5. Setup the CLI to use your Firebase project using firebase use --add and select your Firebase project
  6. Deploy your project's code using firebase deploy
  7. Go to the Firebase Console Storage tab and upload an image. After a short time a thumbnail image with the same name but a thumb_ prefix will be created in the same folder (make sure you refresh the UI to see the new file).


We'd love that you contribute to the project. Before doing so please read our Contributor guide.


© Google, 2016. Licensed under an Apache-2 license.