Node.js Jimp Example to Add Image & Text Watermark or Logo to Images in Command Line Full Project For Beginners

 

 

 

 

 

npm init -y

 

 

npm i jimp-watermark

 

 

index.js

 

 

Adding Image Watermark

 

 

 

 

addWatermark(imageSource, watermarkSource, options)

API to overlay watermark in given image. It takes three arguments :

  1. path of the image
  2. path of the watermark
  3. options object. This argument is optional

Options

Various options supported by this API are :

  • ratio – To specify watermark text. Default is ‘Sample watermark’.
  • opacity – To specify color of watermark text. Default is ‘Grey’.
  • dstPath – To specify the output path. Default is ‘watermark.{sourceFile ext}’.

 

 

Adding Text Watermark on Image

 

 

 

 

addTextWatermark(imageSource, options)

API to overlay watermark in given image. It takes two arguments :

  1. path of the image
  2. options object. This argument is optional

Options

Various options supported by this API are :

  • text – To specify the text to be overlaid on the main image.
  • textSize – To specify size of text over the main image, value ranged from 1 to 8.
  • dstPath – To specify the output path. Default is ‘watermark.{sourceFile ext}’.

 

Leave a Reply