Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
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
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
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).