This module places a watermark in the bottom right corner of your image. An S3 Lambda event can be used to watermark every image that is uploaded to S3.
Note: this is a forked version of lamda-watermark. Changes include:
- addition of "position" property to the options object
- addition of "uploadACL" property to the options object
- This allows you to specify the permissions of the newly created object
- use of an environment variable to specify destination S3 bucket
- additional logging
npm install --save markadamfoster/lambda-watermark
- Create your function (index.js)
'use strict'
var LambdaWatermark = require('lambda-watermark')
var options = {
watermarkImagePath: './watermark.png',
relativeSize: 5,
opacity: 50,
position: 'Center',
watermarkedImageACL: 'public-read'
}
exports.handler = function(event, context) {
console.log('🚨 New image detected!')
new LambdaWatermark(options)(event, context)
}
- Set up Lambda service on AWS
- Zip up your directory (
index.js
, watermark image, andnode_modules
) and upload to your AWS Lambda function - specify the destination bucket as an environment variable
watermarkImagePath
: The relative path to your imagerelativeSize
: The size of the watermark (percent relative to the parent image)opacity
: How opaque the watermark should be. (100 is fully opaque, 0 is fully transparent)position
: Where the watermark should be located on the image. (options are NorthWest|North|NorthEast|West|Center|East|SouthWest|South|SouthEast)- watermarkedImageACL: ACL permissions on the final, watermarked image (i.e. 'public-read')