to-ico icon indicating copy to clipboard operation
to-ico copied to clipboard

Chokes on 512x512px image

Open salomvary opened this issue 9 years ago • 6 comments
trafficstars

If it can't downscale, it should fail with a user friendly exception ("Images larger than 256x256 px are not supported").

$ file icon_512x512.png 
icon_512x512.png: PNG image data, 512 x 512, 8-bit/color RGBA, non-interlaced

$ node_modules/.bin/to-ico icon_512x512.png 
TypeError: "value" argument is out of bounds
    at checkInt (buffer.js:1040:11)
    at Buffer.writeUInt8 (buffer.js:1088:5)
    at createDirectory (node_modules/to-ico/index.js:32:6)
    at Promise.all.then.data (node_modules/to-ico/index.js:98:16)
    at process._tickCallback (internal/process/next_tick.js:103:7)

$ npm list | grep to-ico
└─┬ [email protected]
  └─┬ [email protected]

salomvary avatar Nov 11 '16 18:11 salomvary

Instead of throwing, we could just resize it to 256x256, regardless if resize is true or not. I'm also thinking about setting resize to true by default since it's really fast anyway and you'd want it in most cases.

kevva avatar May 23 '17 19:05 kevva

@kevva if you can tell me which way you'd like it I'd love to send a PR 🙌

albinekb avatar Oct 17 '17 19:10 albinekb

maybe @sindresorhus has the magic answer 🦄 😏

albinekb avatar Oct 17 '17 19:10 albinekb

@albinekb, I think the first step is to just resize the image to 256x256 if it's larger. A PR would be greatly appreciated :+1:.

kevva avatar Oct 18 '17 08:10 kevva

Right.

Also related: https://github.com/kevva/to-ico/issues/20

DanielRuf avatar Oct 11 '19 07:10 DanielRuf

Generally setting the option {resize: true} should prevent that.

DanielRuf avatar Oct 11 '19 08:10 DanielRuf