Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Jimp is an image processing library for Node.js that allows for image manipulation and conversion in a variety of ways. It is written entirely in JavaScript and does not require any native dependencies, making it easy to install and use across different platforms.
Image Manipulation
This code sample demonstrates how to read an image, resize it, change its quality, convert it to greyscale, and then save the edited image.
const Jimp = require('jimp');
// Read the image, resize it and change its quality
Jimp.read('path/to/image.jpg')
.then(image => {
return image
.resize(256, 256) // resize
.quality(60) // set JPEG quality
.greyscale() // set greyscale
.write('path/to/edited-image.jpg'); // save
})
.catch(err => {
console.error(err);
});
Color Manipulation
This code sample shows how to read an image and adjust its brightness before saving it.
const Jimp = require('jimp');
// Read the image and adjust brightness
Jimp.read('path/to/image.jpg')
.then(image => {
return image
.brightness(0.5) // increase brightness by 50%
.write('path/to/brighter-image.jpg'); // save
})
.catch(err => {
console.error(err);
});
Image Conversion
This code sample illustrates how to read an image in one format (JPG) and convert it to another format (PNG) before saving.
const Jimp = require('jimp');
// Read the image and convert it to PNG
Jimp.read('path/to/image.jpg')
.then(image => {
return image
.write('path/to/image.png'); // convert and save as PNG
})
.catch(err => {
console.error(err);
});
Sharp is a high-performance Node.js image processing library that uses the libvips library. It is known for its speed and efficiency, especially for large images and batch processing. Compared to Jimp, Sharp is faster but requires native dependencies.
GraphicsMagick for Node.js (gm) is a wrapper for the GraphicsMagick image processing utility. It provides a wide range of image manipulation capabilities and is suitable for complex tasks. Unlike Jimp, gm relies on the GraphicsMagick or ImageMagick native libraries.
Image-js is a JavaScript library for image manipulation on Node.js and the browser. It provides similar functionalities to Jimp, with a focus on scientific and technical image processing. It is also written in pure JavaScript with no native dependencies.
JavaScript Image Manipulation Program
The "JavaScript Image Manipulation Program" :-)
An image processing library for Node written entirely in JavaScript, with zero native dependencies.
The default jimp configuration.
Supported types:
@jimp/jpeg
@jimp/png
@jimp/bmp
@jimp/tiff
@jimp/gif
npm install --save jimp
const { Jimp } = require("jimp");
// open a file called "lenna.png"
const image = await Jimp.read("test.png");
image.resize(256, 256); // resize
await image.write("test-small.jpg"); // save
FAQs
An image processing library written entirely in JavaScript.
The npm package jimp receives a total of 1,095,279 weekly downloads. As such, jimp popularity was classified as popular.
We found that jimp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.