This module places a watermark in the chosen position of your image. An S3 Lambda event can be used to watermark every image that is uploaded to S3 and to save it as an altered version retaining the original file.
Note: this is a forked version of lamda-watermark which is a forked version of lamda-watermark. Changes features include:
- ability to position water mark
- ability to set the permissions of your created file
- set destination S3 bucket and path
- save a version of the file as '-watermarked' to retain the original
- logging
npm install --save tyroga/lambda-watermark
- Create your function (index.js)
'use strict'
var LambdaWatermark = require('lambda-watermark')
var options = {
watermarkImagePath: './exampleWatermark.png',
relativeSize: 5,
watermarkWidth: 250,
watermarkHeight: 133,
opacity: 50,
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 imagewatermarkWidth
: Width of the watermark imagewatermarkHeight
: Height of the watermark 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')