Installations
npm install @pandell/pngjs-image
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
4.5.0
NPM Version
2.15.9
Score
72.6
Supply Chain
92.9
Quality
70.7
Maintenance
25
Vulnerability
97.9
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
Download Statistics
Total Downloads
1,991
Last Day
1
Last Week
10
Last Month
73
Last Year
313
GitHub Statistics
MIT License
171 Commits
4 Watchers
2 Branches
5 Contributors
Updated on Feb 03, 2025
Bundle Size
788.77 kB
Minified
211.22 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.0.0
Package Id
@pandell/pngjs-image@1.0.0
Size
48.71 kB
NPM Version
2.15.9
Node Version
4.5.0
Total Downloads
Cumulative downloads
Total Downloads
1,991
Last Day
-50%
1
Compared to previous day
Last Week
-37.5%
10
Compared to previous week
Last Month
329.4%
73
Compared to previous month
Last Year
-62.9%
313
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
6
Dev Dependencies
5
PNGjs-Image
JavaScript-based PNG image encoder, decoder, and manipulator
Table of Contents
##Installation
Install this module with the following command:
1npm install pngjs-image
Add the module to your package.json
dependencies:
1npm install --save pngjs-image
Add the module to your package.json
dev-dependencies:
1npm install --save-dev pngjs-image
Require the module in your source-code:
1var PNGImage = require('pngjs-image');
##Usage
Example: Creating a new image
1var image = PNGImage.createImage(100, 300); 2 3// Get width and height 4console.log(image.getWidth()); 5console.log(image.getHeight()); 6 7// Set a pixel at (20, 30) with red, having an alpha value of 100 (half-transparent) 8image.setAt(20, 30, { red:255, green:0, blue:0, alpha:100 }); 9 10// Get index of coordinate in the image buffer 11var index = image.getIndex(20, 30); 12 13// Print the red color value 14console.log(image.getRed(index)); 15 16// Get low level image object with buffer from the 'pngjs' package 17var pngjs = image.getImage(); 18 19image.writeImage('path/to/file', function (err) { 20 if (err) throw err; 21 console.log('Written to the file'); 22});
Example: Loading an image
1PNGImage.readImage('path/to/file', function (err, image) { 2 if (err) throw err; 3 4 // Get width and height 5 console.log(image.getWidth()); 6 console.log(image.getHeight()); 7 8 // Set a pixel at (20, 30) with red, having an alpha value of 100 (half-transparent) 9 image.setAt(20, 30, { red:255, green:0, blue:0, alpha:100 }); 10});
Example: Loading an image from an url
1PNGImage.readImage('https://s.yimg.com/rz/l/yahoo_en-US_f_p_142x37_2x.png', function (err, image) { 2 if (err) throw err; 3 4 // The image is in the 'image' variable if everything went well 5});
###Static-Methods
<PNGImage> = PNGImage.addFilter(key, fn)
Adds thefn
filter with identifierkey
to the filter-list<PNGImage> = PNGImage.createImage(width, height)
Creates an image with the given size<PNGImage> = PNGImage.copyImage(image)
Copies an image into a new containerPNGImage.readImage(path, fn)
Loads an image from the file or url, calling thefn
function when donePNGImage.loadImage(blob, fn)
Loads an image from memory, calling thefn
function when done
###Instance-Methods
<pngjs> = image.getImage()
Gets thepngjs
instance<Buffer> = image.getBlob()
Gets the data as a buffer object<int> = image.getWidth()
Gets the width of the image<int> = image.getHeight()
Gets the height of the imageimage.clip(x, y, width, height)
Clips the current image; the dimensions have to be smaller than the original imageimage.fillRect(x, y, width, height, color)
Fills the rectangle with the supplied colorimage.applyFilters(filters, returnResult)
Applies a list of filters to the image<int> = image.getIndex(x, y)
Converts the x and y coordinates to the sequential index of the image bufferimage.writeImage(path, fn)
Writes the image to the filesystem and calling thefn
function when doneimage.toBlob(fn)
Exports data to a buffer and calling thefn
function when done
####Pixel manipulation
<uint32> = image.getAtIndex(idx)
Gets complete 32-bit pixel at indexidx
<uint32> = image.getAt(x, y)
Gets complete 32-bit pixel at the x and y coordinate<uint32> = image.getPixel(x, y)
Gets complete 32-bit pixel at the x and y coordinateimage.setAtIndex(idx, color)
Sets a specific color at the index. A color left-off will not be modified.image.setAt(x, y, color)
Sets a specific color at the x and y coordinate. A color left-off will not be modified.image.setPixel(x, y, color)
Sets a specific color at the x and y coordinate. A color left-off will not be modified.<uint32> = image.getColorAtIndex(idx)
Gets the color components of the pixel at indexidx
<uint32> = image.getColor(x, y)
Gets the color components of the pixel at the x and y coordinate<uint8> = image.getRed(idx)
Gets the red intensity at an indeximage.setRed(idx, value, opacity)
Sets the red intensity at an index<uint8> = image.getGreen(idx)
Gets the green intensity at an indeximage.setGreen(idx, value, opacity)
Sets the green intensity at an index<uint8> = image.getBlue(idx)
Gets the blue intensity at an indeximage.setBlue(idx, value, opacity)
Sets the blue intensity at an index<uint8> = image.getAlpha(idx)
Gets the alpha intensity at an indeximage.setAlpha(idx, value, opacity)
Sets the alpha intensity at an index
####Pixel conversion
<uint32> = image.getBlurPixelAt(idx, funcName)
Gets the blurred color of a pixel at indexidx
<uint32> = image.getYIQAtIndex(idx)
Gets the YIQ-value of a pixel at indexidx
<uint32> = image.getYIQ(x, y)
Gets the YIQ-value of a pixel at the x and y coordinate<uint32> = image.getLumaAtIndex(idx)
Gets the luma of a pixel at indexidx
<uint32> = image.getLuma(x, y)
Gets the luma of a pixel at the x and y coordinate<uint32> = image.getSepiaAtIndex(idx)
Gets the sepia-color of a pixel at indexidx
<uint32> = image.getSepia(x, y)
Gets the sepia-color of a pixel at the x and y coordinate<uint32> = image.getLuminosityAtIndex(idx)
Gets the luminosity of a pixel at indexidx
<uint32> = image.getLuminosity(x, y)
Gets the luminosity of a pixel at the x and y coordinate<uint32> = image.getLightnessAtIndex(idx)
Gets the lightness of a pixel at indexidx
<uint32> = image.getLightness(x, y)
Gets the lightness of a pixel at the x and y coordinate<uint32> = image.getGrayScaleAtIndex(idx)
Gets the grayscale-value of a pixel at indexidx
<uint32> = image.getGrayScale(x, y)
Gets the grayscale-value of a pixel at the x and y coordinate
###Filters Following filters can be applied to an image:
- blur
- grayScale
- lightness
- luma
- luminosity
- sepia
##API-Documentation
Generate the documentation with following command:
1npm run docs
The documentation will be generated in the docs
folder of the module root.
##Tests
Run the tests with the following command:
1npm run test
The code-coverage will be written to the coverage
folder in the module root.
##Third-party libraries
The following third-party libraries are used by this module:
###Dependencies
- pako: https://github.com/nodeca/pako
- pngjs: https://github.com/niegowski/node-pngjs
- stream-buffers: https://github.com/samcday/node-stream-buffer
- underscore: http://underscorejs.org
- request: https://github.com/request/request
###Dev-Dependencies
- chai: http://chaijs.com
- coveralls: https://github.com/cainus/node-coveralls
- codeclimate-test-reporter: https://github.com/codeclimate/javascript-test-reporter
- istanbul: https://github.com/gotwarlost/istanbul
- mocha: https://github.com/visionmedia/mocha
- sinon: http://sinonjs.org
- sinon-chai: https://github.com/domenic/sinon-chai
- yuidocjs: https://github.com/yui/yuidoc
##License
The MIT License
Copyright 2014-2015 Yahoo Inc.

No vulnerabilities found.
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
no binaries found in the repo
Reason
Found 0/26 approved changesets -- score normalized to 0
Reason
project is archived
Details
- Warn: Repository is archived.
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 5 are checked with a SAST tool
Reason
55 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-pp7h-53gx-mx7r
- Warn: Project is vulnerable to: GHSA-832h-xg76-4gv6
- Warn: Project is vulnerable to: GHSA-3fw8-66wf-pr7m
- Warn: Project is vulnerable to: GHSA-6w62-83g6-rfhj
- Warn: Project is vulnerable to: GHSA-rch9-xh7r-mqgw
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-92vm-wfm5-mxvv
- Warn: Project is vulnerable to: GHSA-9vvw-cc9w-f27h
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9
- Warn: Project is vulnerable to: GHSA-gpvr-g6gh-9mc2
- Warn: Project is vulnerable to: GHSA-cm5g-3pgc-8rg4
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-qrmc-fj45-qfc2
- Warn: Project is vulnerable to: GHSA-9qj9-36jm-prpv
- Warn: Project is vulnerable to: GHSA-qh2h-chj9-jffq
- Warn: Project is vulnerable to: GHSA-jcpv-g9rr-qxrc
- Warn: Project is vulnerable to: GHSA-44pw-h2cw-w3vq
- Warn: Project is vulnerable to: GHSA-jp4x-w63m-7wgm
- Warn: Project is vulnerable to: GHSA-c429-5p7v-vgjp
- Warn: Project is vulnerable to: GHSA-q257-vv4p-fg92
- Warn: Project is vulnerable to: GHSA-4hpf-3wq7-5rpr
- Warn: Project is vulnerable to: GHSA-f522-ffg8-j8r6
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-282f-qqgm-c34q
- Warn: Project is vulnerable to: GHSA-9cw2-jqp5-7x39
- Warn: Project is vulnerable to: GHSA-cfjh-p3g4-3q2f
- Warn: Project is vulnerable to: GHSA-hjcp-j389-59ff
- Warn: Project is vulnerable to: GHSA-vfvf-mqq8-rwqc
- Warn: Project is vulnerable to: GHSA-7px7-7xjx-hxm8
- Warn: Project is vulnerable to: GHSA-x5pg-88wf-qq4p
- Warn: Project is vulnerable to: GHSA-5v2h-r2cx-5xgj
- Warn: Project is vulnerable to: GHSA-rrrm-qjm4-v8hf
- Warn: Project is vulnerable to: GHSA-wrvr-8mpx-r7pp
- Warn: Project is vulnerable to: GHSA-hxm2-r34f-qmc5
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-w9mr-4mfr-499f
- Warn: Project is vulnerable to: GHSA-f9cm-p3w6-xvr3
- Warn: Project is vulnerable to: GHSA-jjv7-qpx3-h62q
- Warn: Project is vulnerable to: GHSA-gqgv-6jq5-jjj9
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-7xfp-9c55-5vqj
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-xwg4-93c6-3h42
- Warn: Project is vulnerable to: GHSA-jgqf-hwc5-hh37
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-2m39-62fm-q8r3
- Warn: Project is vulnerable to: GHSA-mf6x-7mm4-x2g7
- Warn: Project is vulnerable to: GHSA-g7q5-pjjr-gqvp
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-xc7v-wxcw-j472
- Warn: Project is vulnerable to: GHSA-cf4h-3jhx-xvhq
Score
1.7
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More