Skip to content

Instantly share code, notes, and snippets.

@nokenwa
Last active March 24, 2020 11:28
Show Gist options
  • Save nokenwa/3a4acffb9e4af555d80c4145ca409f6d to your computer and use it in GitHub Desktop.
Save nokenwa/3a4acffb9e4af555d80c4145ca409f6d to your computer and use it in GitHub Desktop.
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