- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to blur an image using Node Jimp blur() function?
NodeJS – Blur() is an inbuilt function that is used to blur images. The effect produced by JIMP blur() will be similar to that of the Gaussian blur. It blurs based on the pixels input.
Syntax
blur(r, cb)
Definition of blur() paramters
r – It takes the input for blur and blurs based upon the pixels. If r is 2, it will blur 2 pixels at a time.
cb – This is an optional parameter that can be invoked after the compilation is complete.
Input Image
Using Node JIMP – BLUR()
Before proceeding to use blur() functions, please check that the following statements arealready executed for setting up the environment.
npm init -y // Initialising the Node environment
npm install jimp --save // Installing the jimp dependency
Create a blur.js file and copy-paste the following code snippet in it.
Use node blur.js to run the code.
Note – Note that the method name should match with the JS file name. Only then it will be able to call the desired method.
Example
const Jimp = require('jimp') ; async function blur() { // Function name is same as of file name // Reading Image const image = await Jimp.read ('/home/jimp/tutorials_point_img.jpg'); image.blur(3) .write('/home/jimp/blur.jpg'); } blur(); // Calling the function here using async console.log("Image is processed successfully");
Output
Using Node JIMP – BLUR() with 'cb' parameters
Example
const Jimp = require('jimp') ; async function blur() { // Reading Image const image = await Jimp.read ('/home/jimp/tutorials_point_img.jpg'); image.blur(7, function(err){ if (err) throw err; }) .write('/home/jimp/blur.jpg'); } blur(); console.log("Image is processed successfully");
Output
- Related Articles
- Blurring an image using the OpenCV function blur()
- Blurring an image using the OpenCV function Gaussian Blur()
- How to crop an image using crop() function in Node Jimp?
- How to blur faces in an image using OpenCV Python?
- OpenCV Python Program to blur an image?
- Applying Gaussian Blur to an image using the Pillow library
- Applying Box Blur to an image using the Pillow library
- How to adjust the contrast of an image using contrast() function in Node Jimp?
- How to flip an image in Node Jimp?
- How to resize an image in Node Jimp?
- How to rotate an image in Node Jimp?
- How to add blur-in and blur-out animation to a Polyline using FabricJS?
- How to change an image to greyscale in Node Jimp?
- How to apply Posterize to an image in Node Jimp?
- How to add a blur effect to a text node in JavaFX?
