Skip to content
This repository has been archived by the owner on Sep 17, 2022. It is now read-only.

fix(windows): generate 32x32 ico files #75

Merged
merged 1 commit into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/fix-ico.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauricon": patch
---

Generate 32x32 ICO icons for better compatibility with the window icon on Windows.
11 changes: 2 additions & 9 deletions src/tauricon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,14 +509,7 @@ const tauricon = {
await this.validate(src, target)

const s = sharp(src)
const metadata = await s.metadata()
let icoBuf
if (metadata.width !== metadata.height) {
const size = Math.min(metadata.width ?? 256, metadata.height ?? 256)
icoBuf = await s.resize(size, size).toBuffer()
} else {
icoBuf = await s.toBuffer()
}
const icoBuf = await s.resize(32, 32).toBuffer()

const icns = new Icns()
for (const key in icnsImageList) {
Expand All @@ -532,7 +525,7 @@ const tauricon = {
ensureFileSync(path.join(target, '/icon.icns'))
writeFileSync(path.join(target, '/icon.icns'), icns.data)

const out2 = await pngToIco(icoBuf)
const out2 = await pngToIco([icoBuf])
if (out2 === null) {
throw new Error('Failed to create icon.ico')
}
Expand Down