-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e947527
commit 3e7ecfa
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|