![Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack](https://cdn.sanity.io/images/cgdhsj6q/production/6af25114feaaac7179b18127c83327568ff592d1-1024x1024.webp?w=800&fit=max&auto=format)
Security News
Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
ico-endec
Advanced tools
Readme
This JavaScript library provides an encoder and decoder for ICO and CUR files. Although this library can encode and decode both BMP and PNG images, BMP endec does not provide bitmasking support, and as such, will not work with some icons. However, PNG support is widespread and has become a more defacto standard for application icons, so this problem is largely moot -- but it still would be nice to have.
The encode function takes an array of ArrayBuffers or Buffers that contain BMP or PNG data. It returns a Buffer containing the binary data of the ICO file.
const icoEndec = require('ico-endec')
const fsPromises = require('fs').Promises
(async () => {
let icoBuffer = icoEndec.encode([
await fsPromises.readFile('myIcon-16x16.png'),
await fsPromises.readFile('myIcon-32x32.png'),
await fsPromises.readFile('myIcon-64x64.png')
])
await fsPromises.writeFile('myIcon.ico', icoBuffer)
})()
The decode function takes a Buffer or an ArrayBuffer that holds the binary data of an ICO file. It returns an array of IconEntries.
const icoEndec = require('ico-endec')
const fsPromises = require('fs').Promises
(async () => {
let icons = icoEndec.decode(await fsPromises.readFile('myIcon.ico'))
icons.forEach((icon, index) => {
fsPromises.writeFile(`myIcon-${icon.width}x${icon.height}.${icon.imageType}`, icon.imageData)
})
})()
The IconEntry class stores various information about the given icon entry.
Accessor | Type | Description |
---|---|---|
width | Number | width of the image, maximum of 256 |
height | Number | height of the image, maximum of 256 |
colors | Number | number of colors |
colorPlanes | Number | color planes of an ICO image |
bitsPerPixel | Number | bits per pixel of an ICO image |
horizontalHotspot | Number | horizontal hotspot of a CUR image |
verticalHotspot | Number | vertical hotspot of a CUR image |
imageSize | Number | (interal) size of imageData's buffer |
imageOffset | Number | (interal) offset start of the image data |
imageType | String | 'png' or 'bmp' |
imageData | Buffer | image data of the icon |
FAQs
ICO encoder and decoder library
The npm package ico-endec receives a total of 35,094 weekly downloads. As such, ico-endec popularity was classified as popular.
We found that ico-endec demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.