Skip to content

Allow larger images if intentional #48

@tacman

Description

@tacman

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.

SRWieZ/thumbhash#16 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions