image-parser is a JavaScript library designed for parsing and basic manipulation of images. It primarily leverages `lwip` for image processing, with a mentioned fallback to GraphicsMagick, though the direct integration of GraphicsMagick is not clearly detailed in the quickstart. The current stable version is 1.2.9, with recent releases focusing on documentation updates and maintainer support links rather than feature development. This indicates the project is in a maintenance mode. A key characteristic is its reliance on `lwip`, a library that itself has seen limited maintenance and can present challenges with newer Node.js versions or platform compatibility due to its native dependencies. It allows for parsing image data, accessing individual pixels, resizing, cropping, and saving images.
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
This package is CommonJS-only. Direct ES module import syntax is not supported without a CommonJS wrapper or bundler.
const ImageParser = require("image-parser");
Demonstrates how to parse an image from a URL, retrieve its dimensions and pixel data, then resize it and save the modified image to a local file.
const ImageParser = require("image-parser");
const path = require("path");
const fs = require("fs");
// Ensure the output directory exists for saving images
const outputDir = path.join(__dirname, 'output');
if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir);
}
const imageUrl = "https://octodex.github.com/images/privateinvestocat.jpg";
console.log(`Parsing image from: ${imageUrl}`);
let img = new ImageParser(imageUrl);
img.parse(err => {
if (err) {
console.error("Error parsing image:", err);
return;
}
console.log("Image successfully parsed.");
console.log("Image width:", img.width());
console.log("Image height:", img.height());
console.log("Pixel at (3,3):", img.getPixel(3, 3));
// Example of resizing and saving the image
const newWidth = 100;
const newHeight = 100;
console.log(`Resizing image to ${newWidth}x${newHeight}...`);
img.resize(newWidth, newHeight, (resizeErr) => {
if (resizeErr) {
console.error("Error resizing image:", resizeErr);
return;
}
const outputPath = path.join(outputDir, "resized-image.jpg");
console.log(`Saving resized image to ${outputPath}...`);
img.save(outputPath, (saveErr) => {
if (saveErr) {
console.error("Error saving image:", saveErr);
} else {
console.log(`Resized image saved successfully.`);
}
});
});
});
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.