thumbhash
thumbhash copied to clipboard
Allow larger images if intentional
First, thanks for this very cool library!
My site needs to have thumbnails slightly larger than 100x100, like 120 or so. I'd like to have the option of using those, rather than generating a 100x100 image just to get the thumbhash.
My proposal is to change
export function rgbaToThumbHash(w, h, rgba) {
// Encoding an image larger than 100x100 is slow with no benefit
if (w > 100 || h > 100) throw new Error(`${w}x${h} doesn't fit in 100x100`)
to
export function rgbaToThumbHash(w, h, rgba, maxWidth=100, maxHeight=100) {
// Encoding an image larger than 100x100 is slow with no benefit, but may be useful if larger thumbnail images already exist.
if (w > maxWidth || h > maxHeight) throw new Error(`${w}x${h} doesn't fit in ${maxWidth}x{$maxHeight`)
Thank you for your consideration. By doing this, other implementations who are mirroring your code exactly can also implement it, e.g.
https://github.com/SRWieZ/thumbhash/issues/16#issuecomment-2662747835