Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

Google Cloud Platform logo

Google Cloud Functions ImageMagick sample

This sample shows you how to blur an image using ImageMagick in a Storage-triggered Cloud Function.

View the source code.

Deploy and Test

  1. Follow the Cloud Functions quickstart guide to setup Cloud Functions for your project.

  2. Clone this repository:

     git clone https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git
     cd nodejs-docs-samples/functions/imagemagick
    
  3. Create a Cloud Storage bucket for storing images (if you already have one you want to use, you can skip this step):

     gsutil mb gs://YOUR_BUCKET_NAME
    
    • Replace YOUR_BUCKET_NAME with the name of your image Bucket.
  4. Create a Cloud Storage Bucket to stage our deployment:

     gsutil mb gs://YOUR_STAGE_BUCKET_NAME
    
    • Replace YOUR_STAGE_BUCKET_NAME with the name of your Cloud Storage Bucket.
  5. Deploy the blurOffensiveImages function with a Storage trigger:

     gcloud alpha functions deploy blurOffensiveImages --trigger-bucket=YOUR_BUCKET_NAME --stage-bucket=YOUR_STAGE_BUCKET_NAME
    
    • Replace YOUR_BUCKET_NAME with the name of your image Cloud Storage Bucket.
    • Replace YOUR_STAGE_BUCKET_NAME with the name of your Cloud Storage Bucket.
  6. Upload an offensive image to your image Storage bucket, such as this image of a flesh-eating zombie: https://cdn.pixabay.com/photo/2015/09/21/14/24/zombie-949916_1280.jpg

  7. Check the logs for the blurOffensiveImages function:

    gcloud beta functions get-logs blurOffensiveImages
    

    You should see something like this in your console:

    D      ... User function triggered, starting execution
    I      ... `The image zombie.jpg has been detected as inappropriate.`
    D      ... Execution took 1 ms, user function completed successfully