You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Nicolas Garnier dc2519ea4a Updating version of the firebase-functions module in package.json files to launch version 8 years ago
..
functions Updating version of the firebase-functions module in package.json files to launch version 8 years ago
README.md Updating "Firebase" Functions and Storage naming following the rebranding to "Cloud". 8 years ago
firebase.json Adding a convert image sample 8 years ago

README.md

Automatically Convert Images

This sample demonstrates how to automatically convert images that are uploaded to Firebase Storage to JPEG using ImageMagick.

Functions Code

See file functions/index.js for the image conversion code.

The image conversion is performed using ImagMagick which is installed by default on all Cloud Functions instances. This is a CLI so we execute the command from node using the child-process-promise package. The image is first downloaded locally from the Firebase Storage bucket to the tmp folder using the google-cloud SDK.

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:

  • Create a Firebase project on the Firebase Console and visit the Storage tab.
  • Deploy your project using firebase deploy
  • Go to the Firebase Console Storage tab and upload an image that is not a JPEG, for instance a PNG. After a short time an image with the same base name but the .jpg extension will be created in the same folder (make sure you refresh the UI to see the new file).