Skip to content

Commit

Permalink
Document addDarkIcns
Browse files Browse the repository at this point in the history
  • Loading branch information
JrMasterModelBuilder committed Jan 24, 2024
1 parent e947527 commit 3e7ecfa
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,46 @@ await icns.addFromPng(await readFile('icon/[email protected]'), ['ic11'], raw);
await writeFile('icon.icns', icns.encode());
```

### macOS ICNS with dark mode (current formats)

```js
import {readFile, writeFile} from 'node:fs/promises';
import {IconIcns} from '@shockpkg/icon-encoder';

const icns = new IconIcns();
icns.toc = true;

// First insert light images.
await icns.addFromPng(await readFile('light/[email protected]'), ['ic12']);
await icns.addFromPng(await readFile('light/128x128.png'), ['ic07']);
await icns.addFromPng(await readFile('light/[email protected]'), ['ic13']);
await icns.addFromPng(await readFile('light/256x256.png'), ['ic08']);
await icns.addFromPng(await readFile('light/16x16.png'), ['ic04']);
await icns.addFromPng(await readFile('light/[email protected]'), ['ic14']);
await icns.addFromPng(await readFile('light/512x512.png'), ['ic09']);
await icns.addFromPng(await readFile('light/32x32.png'), ['ic05']);
await icns.addFromPng(await readFile('light/[email protected]'), ['ic10']);
await icns.addFromPng(await readFile('light/[email protected]'), ['ic11']);

// Create and embed the dark variant.
const dark = new IconIcns();
dark.toc = icns.toc;
await dark.addFromPng(await readFile('dark/[email protected]'), ['ic12']);
await dark.addFromPng(await readFile('dark/128x128.png'), ['ic07']);
await dark.addFromPng(await readFile('dark/[email protected]'), ['ic13']);
await dark.addFromPng(await readFile('dark/256x256.png'), ['ic08']);
await dark.addFromPng(await readFile('dark/16x16.png'), ['ic04']);
await dark.addFromPng(await readFile('dark/[email protected]'), ['ic14']);
await dark.addFromPng(await readFile('dark/512x512.png'), ['ic09']);
await dark.addFromPng(await readFile('dark/32x32.png'), ['ic05']);
await dark.addFromPng(await readFile('dark/[email protected]'), ['ic10']);
await dark.addFromPng(await readFile('dark/[email protected]'), ['ic11']);
icns.addDarkIcns(dark.encode());

// Write the icon with the dark icon embeded.
await writeFile('icon.icns', icns.encode());
```

### macOS ICNS (legacy formats)

```js
Expand Down

0 comments on commit 3e7ecfa

Please sign in to comment.