{"id":13323,"library":"image-parser","title":"Image Parser","description":"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.","status":"maintenance","version":"1.2.9","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/IonicaBizau/image-parser","tags":["javascript","image","parser","an","that","works"],"install":[{"cmd":"npm install image-parser","lang":"bash","label":"npm"},{"cmd":"yarn add image-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add image-parser","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Primary image processing backend, relies on native bindings and has known compatibility issues with newer Node.js versions.","package":"lwip"}],"imports":[{"note":"This package is CommonJS-only. Direct ES module import syntax is not supported without a CommonJS wrapper or bundler.","wrong":"import ImageParser from 'image-parser';","symbol":"ImageParser","correct":"const ImageParser = require(\"image-parser\");"}],"quickstart":{"code":"const ImageParser = require(\"image-parser\");\nconst path = require(\"path\");\nconst fs = require(\"fs\");\n\n// Ensure the output directory exists for saving images\nconst outputDir = path.join(__dirname, 'output');\nif (!fs.existsSync(outputDir)) {\n    fs.mkdirSync(outputDir);\n}\n\nconst imageUrl = \"https://octodex.github.com/images/privateinvestocat.jpg\";\nconsole.log(`Parsing image from: ${imageUrl}`);\n\nlet img = new ImageParser(imageUrl);\n\nimg.parse(err => {\n    if (err) {\n        console.error(\"Error parsing image:\", err);\n        return;\n    }\n\n    console.log(\"Image successfully parsed.\");\n    console.log(\"Image width:\", img.width());\n    console.log(\"Image height:\", img.height());\n    console.log(\"Pixel at (3,3):\", img.getPixel(3, 3));\n\n    // Example of resizing and saving the image\n    const newWidth = 100;\n    const newHeight = 100;\n    console.log(`Resizing image to ${newWidth}x${newHeight}...`);\n    img.resize(newWidth, newHeight, (resizeErr) => {\n        if (resizeErr) {\n            console.error(\"Error resizing image:\", resizeErr);\n            return;\n        }\n        const outputPath = path.join(outputDir, \"resized-image.jpg\");\n        console.log(`Saving resized image to ${outputPath}...`);\n        img.save(outputPath, (saveErr) => {\n            if (saveErr) {\n                console.error(\"Error saving image:\", saveErr);\n            } else {\n                console.log(`Resized image saved successfully.`);\n            }\n        });\n    });\n});","lang":"javascript","description":"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."},"warnings":[{"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.","message":"The 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.","severity":"breaking","affected_versions":">=1.0.0"},{"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.","message":"This 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`.","severity":"gotcha","affected_versions":">=1.2.7"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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`.","cause":"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.","error":"Cannot find module 'lwip' or 'image-parser' fails to install with native module errors."},{"fix":"Use the CommonJS `require` syntax: `const ImageParser = require('image-parser');`.","cause":"Attempting to use ES module import syntax (e.g., `import ImageParser from 'image-parser';`) for this CommonJS-only package.","error":"TypeError: ImageParser is not a constructor"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null}