Exciting release!Introducing "safe npm". Learn more
Socket
Log inDemoInstall

@shockpkg/icon-encoder

Package Overview
Dependencies
2
Maintainers
1
Versions
17
Issues
File Explorer

Advanced tools

@shockpkg/icon-encoder

Package for encoding different icon files

    2.1.3latest
    GitHub

Version published
Maintainers
1
Weekly downloads
689
decreased by-34.75%

Weekly downloads

Readme

Source

Icon Encoder

Package for encoding different icon files

npm node

size downloads

Build Status

Overview

Encoders for Windows ICO and macOS ICNS files with fine grain control.

NOTE: Not all encode formats are currently supported but the major ones are.

Usage

CLI Usage

$ npx @shockpkg/icon-encoder $ npm exec @shockpkg/icon-encoder $ npm exec shockpkg-icon-encoder Usage: shockpkg-icon-encoder [options...] (icon.ico | icon.icns) pngs... -v, --version Show the current version. -h, --help Show this help message. --raw Prefer raw png data in icon. --png Prefer png encoding in ico. --bmp Prefer bmp encoding in ico. --toc Include TOC entry in icns.

API Usage

Windows ICO

import fs from 'fs'; import {IconIco} from '@shockpkg/icon-encoder'; // Default null automatically compresses icons for backwards compatibility. // Pass true to force icons to be PNG encoded, or false to force BMP. const png = null; // Default is to decode and re-encode the PNG data. // Pass true to use the raw PNG input data when using PNG data in the icon. const raw = false; const ico = new IconIco(); ico.addFromPng(fs.readFileSync('icon/256x256.png'), png, raw); ico.addFromPng(fs.readFileSync('icon/128x128.png'), png, raw); ico.addFromPng(fs.readFileSync('icon/64x64.png'), png, raw); ico.addFromPng(fs.readFileSync('icon/48x48.png'), png, raw); ico.addFromPng(fs.readFileSync('icon/32x32.png'), png, raw); ico.addFromPng(fs.readFileSync('icon/16x16.png'), png, raw); fs.writeFileSync('icon.ico', ico.encode());

macOS ICNS (current formats)

import fs from 'fs'; import {IconIcnc} from '@shockpkg/icon-encoder'; const icns = new IconIcnc(); // Optionally include the TOC (table of contents) header. // Newer icons will often include this, the default is false. icns.toc = true; // Default is to decode and re-encode the PNG data. // Pass true to use the raw PNG input data when using PNG data in the icon. const raw = false; // This order matches that of iconutil with the same image set in macOS 10.14. // Images with @2x are just 2x the size their file name suggests. icns.addFromPng(fs.readFileSync('icon/32x32@2x.png'), ['ic12'], raw); icns.addFromPng(fs.readFileSync('icon/128x128.png'), ['ic07'], raw); icns.addFromPng(fs.readFileSync('icon/128x128@2x.png'), ['ic13'], raw); icns.addFromPng(fs.readFileSync('icon/256x256.png'), ['ic08'], raw); icns.addFromPng(fs.readFileSync('icon/16x16.png'), ['ic04'], raw); icns.addFromPng(fs.readFileSync('icon/256x256@2x.png'), ['ic14'], raw); icns.addFromPng(fs.readFileSync('icon/512x512.png'), ['ic09'], raw); icns.addFromPng(fs.readFileSync('icon/32x32.png'), ['ic05'], raw); icns.addFromPng(fs.readFileSync('icon/512x512@2x.png'), ['ic10'], raw); icns.addFromPng(fs.readFileSync('icon/16x16@2x.png'), ['ic11'], raw); fs.writeFileSync('icon.icns', icns.encode());

macOS ICNS (legacy formats)

import fs from 'fs'; import {IconIcnc} from '@shockpkg/icon-encoder'; const icns = new IconIcnc(); icns.addFromPng(fs.readFileSync('icon/16x16.png'), ['is32', 's8mk']); icns.addFromPng(fs.readFileSync('icon/32x32.png'), ['il32', 'l8mk']); icns.addFromPng(fs.readFileSync('icon/48x48.png'), ['ih32', 'h8mk']); icns.addFromPng(fs.readFileSync('icon/128x128.png'), ['it32', 't8mk']); fs.writeFileSync('icon.icns', icns.encode());

Bugs

If you find a bug or have compatibility issues, please open a ticket under issues section for this repository.

License

Copyright (c) 2019-2022 JrMasterModelBuilder

Licensed under the Mozilla Public License, v. 2.0.

If this license does not work for you, feel free to contact me.

Keywords

FAQs

Last updated on 04 Nov 2022

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket
support@socket.devSocket SOC 2 Logo

Product

  • Package Issues
  • 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