Last active
March 24, 2020 11:28
-
-
Save nokenwa/3a4acffb9e4af555d80c4145ca409f6d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cloudinary = require('cloudinary').v2; | |
exports.handler = function(context, event, callback){ | |
const pictureWidth = 1200; | |
const pictureHeight = 1600; | |
const ratio = pictureWidth / pictureHeight; | |
const message = `${event.message} - ${event.Name}`; | |
const cloudinaryTransforms = { | |
transformation: [ | |
{ aspect_ratio: ratio, crop: 'crop' }, | |
{ height: pictureHeight, crop: 'scale' }, | |
{ overlay: { | |
font_family: "Cookie", | |
font_size: 80, | |
width: (pictureWidth-120), | |
text: message, | |
}, | |
} | |
], | |
}; | |
const background = 'blank.png'; | |
const url = cloudinary.url(background, cloudinaryTransforms); //CLOUDINARY NEEDS ENVIRONMENT VARIABLE 'CLOUDINARY_URL' | |
callback(null, { picture: url}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment