Socket
Socket
Sign inDemoInstall

node-zopflipng

Package Overview
Dependencies
3
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-zopflipng

Native module for zopflipng


Version published
Maintainers
1
Install size
10.2 MB
Created

Changelog

Source

2.0.0 (2023-03-09)

⚠ BREAKING CHANGES

  • removes armv6 builds
  • drop support for Node.js 10 and 12

Features

  • deps: update lodepng to version 20221108 (#289) (df6b7ec)
  • use an older glibc version for linux-arm64 builds to improve compatability (810f9df)

Miscellaneous Chores

  • drop support for Node.js 10 and 12 (a6b2db3)
  • removes armv6 builds (e7f4217)

Readme

Source

node-zopflipng

npm Built on N-API v3 CI

Node.js bindings for zopflipng.

Optimizes PNG images for size. This is very slow and should only be done for static resources.

Install

$ npm install --save node-zopflipng

Usage

const {optimizeZopfliPng} = require('node-zopflipng');
const {readFile, writeFile} = require('fs/promises');

readFile('./raw.png')
.then(buffer => optimizeZopfliPng(buffer))
.then(buffer => writeFile('./optimized.png', buffer));

API

optimizeZopfliPng(input, [options]): Promise
input

Type: Buffer

options

Type: Object

See Options for possible values.

optimizeZopfliPngSync(input, [options]): Buffer

Using this function is strongly discouraged. Running zopflipng can easily take more than 30s even on relatively small images (< 1 MB). optimizeZopfliPngSync will block the entire process during this time.

input

Type: Buffer

options

Type: Object

See Options for possible values.

Options

NameTypeDefaultLosslessDescription
lossyTransparentbooleanfalseRemove colors behind alpha channel 0. No visual difference, removes hidden information.
lossy8bitbooleanfalseConvert 16-bit per channel image to 8-bit per channel.
morebooleanfalseCompress more. Uses more iterations depending on file size.
iterationsinteger15/5 (small/large)Number of iterations, more iterations makes it slower but provides slightly better compression. Default: 15 for small files, 5 for large files. Overrides more option.
keepChunksstring[][]Keep metadata chunks with these names that would normally be removed, e.g. tEXt, zTXt, iTXt, gAMA. Due to adding extra data, this increases the result size. By default ZopfliPNG only keeps (and losslessly modifies) the following chunks because they are essential: IHDR, PLTE, tRNS, IDAT and IEND.

Keywords

FAQs

Last updated on 10 Mar 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc