Socket
Socket
Sign inDemoInstall

imagemin-upng

Package Overview
Dependencies
3
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0 to 1.2.0

37

index.js

@@ -1,25 +0,32 @@

'use strict';
'use strict'
var isPng = require('is-png');
var UPNG = require('upng-js');
var UPNG = require('upng-js')
var isPng = require('is-png')
module.exports = function(options) {
options = Object.assign({cnum: 256}, options);
options = Object.assign({cnum: 256}, options)
return function(buffer) {
if (!Buffer.isBuffer(buffer)) {
return Promise.reject(new TypeError('Expected a buffer'));
return function(input) {
if (!Buffer.isBuffer(input)) {
return Promise.reject(new TypeError('Expected a buffer'))
}
if (!isPng(buffer)) {
return Promise.resolve(buffer);
if (!isPng(input)) {
return Promise.resolve(input)
}
var img = UPNG.decode(buffer);
var rgba = UPNG.toRGBA8(img);
var img = UPNG.decode(input)
var dels = img.frames.map(function(frame) {
return frame.delay
})
var rgba = UPNG.toRGBA8(img)
var newBuffer = Buffer.from(UPNG.encode(rgba, img.width, img.height, options.cnum));
var buffer = Buffer.from(
UPNG.encode(rgba, img.width, img.height, options.cnum, dels)
)
return Promise.resolve(newBuffer.byteLength < buffer.byteLength ? newBuffer : buffer);
};
};
return Promise.resolve(
buffer.byteLength < input.byteLength ? buffer : input
)
}
}
{
"name": "imagemin-upng",
"version": "1.1.0",
"version": "1.2.0",
"description": "upng imagemin plugin",

@@ -25,2 +25,4 @@ "license": "MIT",

"optimize",
"png",
"apng",
"upng",

@@ -31,4 +33,11 @@ "upng-js"

"is-png": "^1.0.0",
"upng-js": "^1.0.0"
"upng-js": "^2.0.0"
},
"scripts": {
"test": "eslint index.js && ava",
"publish": "npm --registry=https://registry.npmjs.org/ publish"
},
"devDependencies": {
"ava": "*"
}
}

@@ -12,3 +12,2 @@ # imagemin-upng

## Usage

@@ -48,5 +47,4 @@

## License
MIT © [imagemin](https://github.com/imagemin)
MIT © [fisker Cheung](https://github.com/fisker)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc