ico-to-png
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

ICO to PNG

Convert an ICO file to a PNG file.

Installation

npm install --save ico-to-png

Usage

const icoToPng = require('ico-to-png')
const fs = require('fs')
 
const source = fs.readFileSync('favicon.ico')
 
icoToPng(source, 128).then((png) => {
  console.log(png)
  //=> <Buffer 89 50 4e 47 0d 0a 1a 0a ... >
})

API

icoToPng(source, size[, options]) => Promise<Buffer>

Extracts an image of the requestsed size, and returns a Promise of the raw PNG data.

If no image of that exact size is present in the source file, a suitable larger image will be downsized to the requested size. If a larger image isn't present, the largest image will be returned.

This means that the the returned file could potentially be smaller than the requested size. If you always want exactly the size specified, pass the scaleUp: true to scale up the largest image, instead of returning it as is.

Readme

Keywords

none

Package Sidebar

Install

npm i ico-to-png

Weekly Downloads

1,056

Version

0.2.1

License

MIT

Unpacked Size

3.04 kB

Total Files

4

Last publish

Collaborators

  • linusu