Registry / data / image-parser

image-parser

JSON →
library1.2.9jsnpmunverified

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.

npm install image-parser
INSTALL
IMPORT
SIG · IMAGE-PARSER
I
image-parser
datajavascriptv1.2.9
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ImageParser
const ImageParser = require("image-parser");
import ImageParser from 'image-parser';
This package is CommonJS-only. Direct ES module import syntax is not supported without a CommonJS wrapper or bundler.

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.`); } }); }); });
Debug
Known issues
breakingThe underlying `lwip` library, which `image-parser` heavily relies on, is largely unmaintained and has known compatibility issues with newer Node.js versions (e.g., Node.js 12+ or 14+ may fail to compile native modules). This can lead to installation failures or runtime errors.
fix
Consider using modern, actively maintained alternatives like `sharp` or `jimp` for new projects or if encountering installation issues. If you must use `image-parser`, ensure you are on an older, compatible Node.js version and that necessary system libraries for `lwip` compilation are installed.
affects: >=1.0.0
gotchaThis package appears to be in maintenance mode, with recent releases primarily addressing documentation and maintainer support links. New features are unlikely, and long-term compatibility with evolving Node.js ecosystems is a significant concern due to its dependency on `lwip`.
fix
For new development, evaluate actively maintained image processing libraries such as `sharp` or `jimp`, which offer better performance, broader platform support, and more robust feature sets.
affects: >=1.2.7
Errors
Common errors & fixes
Cannot find module 'lwip' or 'image-parser' fails to install with native module errors.
The `lwip` dependency, which is a native Node.js module, failed to compile during installation, often due to incompatible Node.js versions or missing system build tools.
fix
Ensure your Node.js version is compatible with `lwip` (typically older versions like Node.js 10 or 11 are more stable for `lwip`). Install necessary system-level build tools (e.g., `build-essential` on Linux, Xcode command line tools on macOS, Visual Studio build tools on Windows). Try reinstalling with `npm rebuild` or `npm install --unsafe-perm`.
TypeError: ImageParser is not a constructor
Attempting to use ES module import syntax (e.g., `import ImageParser from 'image-parser';`) for this CommonJS-only package.
fix
Use the CommonJS `require` syntax: `const ImageParser = require('image-parser');`.
Upgrade
Version history
1.2.9latest on npm
Audit
Dependencies
lwiprequiredPrimary image processing backend, relies on native bindings and has known compatibility issues with newer Node.js versions.
Agent activity
4 hits · last 30 days
node
4
Resources
image-parser — npm install image-parser · libregistry