TypeScript tool to create .icns with a built-in icns generator or the macOS icontool
Supports PNG, SVG and many formats for input. outputs icns files with PNG and RLE-encoded image formats
$ yarn install
$ yarn build
$ bin/make-icns iconfile.png [output-name]
$ yarn add --global icon-tool-mac
or
$ npm install -g icon-tool-mac
$ make-icns iconfile.png [output-name]
$ yarn add icon-tool-mac
or
$ npm i icon-tool-mac
import { IconCreatorSharp } from 'icon-tool-mac';
let creator = new IconCreatorSharp(source_file);
creator.convert()
.then((icon: Buffer) => {
// .. do something with the .icns buffer
})
.catch((error: string) => console.error(error));
If you want to do additional image manipulations before creating the .icns:
//Additional import
import { SharpInstance } from 'sharp';
creator.setImageManipulation((image:SharpInstance,size:number) => {
image.flop(true);
});
const IconCreatorSharp = require('icon-tool-mac').IconCreatorSharp;
let creator = new IconCreator(source_file);
creator.convert()
.then((icon) => {
// .. do something with the .icns buffer
})
.catch(error => console.error(error));
Check the /lib/ folder to find other implementations relying on the icontool generator provided by macOS