Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pngjs

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pngjs - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

coverage/base.css

19

lib/bitpacker.js

@@ -20,2 +20,13 @@ 'use strict';

var bgColor = options.bgColor || {};
if (bgColor.red === undefined) {
bgColor.red = 255;
}
if (bgColor.green === undefined) {
bgColor.green = 255;
}
if (bgColor.blue === undefined) {
bgColor.blue = 255;
}
for (var y = 0; y < height; y++) {

@@ -30,2 +41,8 @@ for (var x = 0; x < width; x++) {

alpha = data[inIndex + 3];
if (!outHasAlpha) {
alpha /= 255;
red = Math.min(Math.max(Math.round((1 - alpha) * bgColor.red + alpha * red), 0), 255);
green = Math.min(Math.max(Math.round((1 - alpha) * bgColor.green + alpha * green), 0), 255);
blue = Math.min(Math.max(Math.round((1 - alpha) * bgColor.blue + alpha * blue), 0), 255);
}
}

@@ -49,2 +66,2 @@ else {

return outData;
};
};

@@ -0,0 +0,0 @@ 'use strict';

2

package.json
{
"name": "pngjs",
"version": "2.0.0",
"version": "2.1.0",
"description": "PNG encoder/decoder in pure JS, supporting any bit size & interlace, async & sync with full test suite.",

@@ -5,0 +5,0 @@ "contributors": [

@@ -1,2 +0,2 @@

[![Build Status](https://travis-ci.org/lukeapage/pngjs2.svg?branch=master)](https://travis-ci.org/lukeapage/pngjs2) [![Build status](https://ci.appveyor.com/api/projects/status/tb8418jql1trkntd/branch/master?svg=true)](https://ci.appveyor.com/project/lukeapage/pngjs2/branch/master) [![Coverage Status](https://coveralls.io/repos/lukeapage/pngjs2/badge.svg?branch=master&service=github)](https://coveralls.io/github/lukeapage/pngjs2?branch=master) [![npm version](https://badge.fury.io/js/pngjs2.svg)](http://badge.fury.io/js/pngjs2)
[![Build Status](https://travis-ci.org/lukeapage/pngjs.svg?branch=master)](https://travis-ci.org/lukeapage/pngjs) [![Build status](https://ci.appveyor.com/api/projects/status/tb8418jql1trkntd/branch/master?svg=true)](https://ci.appveyor.com/project/lukeapage/pngjs2/branch/master) [![Coverage Status](https://coveralls.io/repos/lukeapage/pngjs2/badge.svg?branch=master&service=github)](https://coveralls.io/github/lukeapage/pngjs2?branch=master) [![npm version](https://badge.fury.io/js/pngjs.svg)](http://badge.fury.io/js/pngjs)

@@ -118,2 +118,4 @@ pngjs

- `inputHasAlpha` - whether the input bitmap has 4 bits per pixel (rgb and alpha) or 3 (rgb - no alpha).
- `bgColor` - an object containing red, green, and blue values between 0 and 255
that is used when packing a PNG if alpha is not to be included (default: 255,255,255)

@@ -210,2 +212,26 @@

## Packing a PNG and removing alpga (RGBA to RGB)
When removing the alpha channel from an image, there needs to be a background color to correctly
convert each pixel's transparency to the appropriate RGB value. By default, pngjs will flatten
the image against a white background. You can override this in the options:
```js
var fs = require('fs'),
PNG = require('pngjs').PNG;
fs.createReadStream('in.png')
.pipe(new PNG({
colorType: 2,
bgColor: {
red: 0,
green: 255,
blue: 0
}
}))
.on('parsed', function() {
this.pack().pipe(fs.createWriteStream('out.png'));
});
```
# Sync API

@@ -238,2 +264,6 @@

### 2.1.0 - 28/10/2015
- rename package to pngjs
- added 'bgColor' option
### 2.0.0 - 08/10/2015

@@ -240,0 +270,0 @@ - fixes to readme

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc