woltapp/blurhash

Decode produces massive image in dimensions

ivanjaros opened this issue · 2 comments

The example to decode the image produces image that is 300x150px instead of 32x32px for some reason. Any idea why?

   if (isBlurhashValid(hash) === false) {
      return ""
    }
    const pixels = decode(hash, 32, 32);
    const canvas = document.createElement("canvas");
    const ctx = canvas.getContext("2d");
    const imageData = ctx.createImageData(32, 32);
    imageData.data.set(pixels);
    ctx.putImageData(imageData, 0, 0);
    return canvas.toDataURL('image/jpeg', 1)

obrázok

Could you try to set the canvas' width and height to match the width and height you want?

If that doesn't work, please provide a Codesandbox or Stackblitz reproduction.

canvas.width = 32;
canvas.height = 32;

worked. i though the const imageData = ctx.createImageData(32, 32); will handle this.