You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@targos Thanks for such a nice library! Just sharing something I found unexpected (after trying to switch to fast-png from pngjs):
If you want to manipulate pixel data after decoding an indexed image, you have to normalize it into RGBA (from palette + indices) manually. This is 1) not documented, 2) inconvenient. Maybe worth adding a normalize option to decode?
The format of the palette property is [[r, g, b], [r, g, b]], which is inefficient — allocating more memory than necessary. Since we know the number of colors before hand, ideally this would be returned in flat typed form — Uint8ClampedArray([r, g, b, r, g, b, ...]).
The text was updated successfully, but these errors were encountered:
A normalize options sounds good. Do you think it should be a general option (that would normalize any image to 32-bit RGBA) or just something that handles palette conversion? Would you like to work on it?
It is true that using an array of arrays takes more memory. But I'm not sure it's worth changing it, because the palette may contain at most 256 entries.
@targos Thanks for such a nice library! Just sharing something I found unexpected (after trying to switch to
fast-png
frompngjs
):normalize
option todecode
?palette
property is[[r, g, b], [r, g, b]]
, which is inefficient — allocating more memory than necessary. Since we know the number of colors before hand, ideally this would be returned in flat typed form —Uint8ClampedArray([r, g, b, r, g, b, ...])
.The text was updated successfully, but these errors were encountered: