Skip to content

WebNinjaDeveloper.com

Programming Tutorials




Menu
  • Home
  • Youtube Channel
  • Official Blog
  • Nearby Places Finder
  • Direction Route Finder
  • Distance & Time Calculator
Menu

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

Posted on January 23, 2023

 

 

Welcome folks today in this blog post we will be using the jimp library to add the text and image watermark inside images in node.js. All the full source code of the application is shown below.

 

 

Get Started

 

 

In order to get started you need to make a new node.js project using the below command as shown below

 

 

npm init -y

 

 

npm i jimp-watermark

 

 

And after that you will be seeing the below directory structure of the node.js app

 

 

 

 

 

Now we need to copy paste the below code to add the text watermark on top of the profile.png image file as shown below

 

 

index.js

 

 

JavaScript
1
2
3
4
5
6
7
8
9
10
11
let watermark = require('jimp-watermark')
 
let options = {
    'ratio':0.9,
    'opacity':0.9,
    'dstPath':'./watermark.jpg',
    'text':'John Williamson',
    'textSize':8
}
 
watermark.addTextWatermark('profile.png',options)

 

 

As you can see we are importing the jimp package and inside it we are controlling the opacity and the text property what text you want to write and then we are controlling the size of the text passing the value from 1 to 8. And then we are using the addTextWatermark() method to add the text logo on image passing the input image and the options.

 

 

 

 

 

Now we will be adding the image or logo watermark to the input image using the addWatermark() method and passing the options as shown below

 

 

index.js

 

 

JavaScript
1
2
3
4
5
6
7
8
9
let watermark = require('jimp-watermark')
 
let options = {
    'ratio':0.9,
    'opacity':0.9,
    'dstPath':'./watermark.jpg'
}
 
watermark.addWatermark('profile.png','logo.png',options)

 

 

Recent Posts

  • Android Java Project to Download Multiple Images From URL With Progressbar & Save it inside Gallery
  • Android Java Project to Capture Image From Camera & Save it inside Gallery
  • Android Java Project to Crop,Scale & Rotate Images Selected From Gallery and Save it inside SD Card
  • Android Kotlin Project to Load Image From URL into ImageView Widget
  • Android Java Project to Make HTTP Call to JSONPlaceholder API and Display Data in RecyclerView Using GSON & Volley Library
  • Angular
  • Bunjs
  • C#
  • Deno
  • django
  • Electronjs
  • java
  • javascript
  • Koajs
  • kotlin
  • Laravel
  • meteorjs
  • Nestjs
  • Nextjs
  • Nodejs
  • PHP
  • Python
  • React
  • ReactNative
  • Svelte
  • Tutorials
  • Vuejs




©2023 WebNinjaDeveloper.com | Design: Newspaperly WordPress Theme