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

node-pngquant-native

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-pngquant-native

pngquant native plugin of node

  • 0.0.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
172
increased by13.16%
Maintainers
1
Weekly downloads
 
Created
Source

node-pngquant-native

NPM version

node-pngquant-native是一个node的native插件,而不是调用命令行的方式,提升处理速率,有效的省去了调用外部程序产生的时间开销。

install

npm install -g node-pngquant-native

require

  • 编译pngquant,编译器必须支持C99
  • 符合node-gyp环境要求
  • Windows用户,如果安装失败,请clone win32分支进行编译

use


var pngquant = require('node-pngquant-native');

fs.readFile('./alphatest.png', function (err, buffer) {
  if (err) throw err;
  var resBuffer = pngquant.compress(buffer, {
    "speed": 1 //1 ~ 11
  });

  fs.writeFile('./alphatest_out.png', resBuffer, {
      flags: 'wb'
  }, function(err){});
});

Api

pngquant.compress(buffer, option)

var pngquant = require('node-pngquant-native')
var option = {
    speed: 11
    //...    
}

var resBuffer = pngquant.compress(buffer, option);

option
  • option.speed

    Speed/quality trade-off from 1 (brute-force) to 11 (fastest). The default is 3. Speed 10 has 5% lower quality, but is 8 times faster than the default. Speed 11 disables dithering and lowers compression level.

    var opt = {
        speed: 11
    }
    
  • option.quality = [min, max]

    min and max are numbers in range 0 (worst) to 100 (perfect), similar to JPEG. pngquant will use the least amount of colors required to meet or exceed the max quality. If conversion results in quality below the min quality the image won't be saved (if outputting to stdin, 24-bit original will be output) and pngquant will exit with status code 99.

    var opt = {
        quality: [40, 60]
    }
    
  • option.iebug

    Workaround for IE6, which only displays fully opaque pixels. pngquant will make almost-opaque pixels fully opaque and will avoid creating new transparent colors.

    var opt = {
        isbug: true
    }
    

Keywords

FAQs

Package last updated on 30 Apr 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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