Pixel Data JS - v0.28.0
    Preparing search index...

    Function resizeImageData

    • Non destructively resizes the ImageData buffer to new dimensions, optionally offsetting the original content. This operation creates a new buffer. It does not scale or stretch pixels; instead, it crops or pads the image based on the new dimensions and provides an offset for repositioning.

      Parameters

      • target: ImageDataLike

        The target to resize.

      • newWidth: number

        The target width in pixels.

      • newHeight: number

        The target height in pixels.

      • offsetX: number = 0

        The horizontal offset for placing the original image within the new buffer.

      • offsetY: number = 0

        The vertical offset for placing the original image within the new buffer.

      Returns ImageData

      A new ImageData instance with the specified dimensions.

      // Centers an 80x80 image in a new 100x100 buffer
      const resized = resizeImageData(
      originalData,
      100,
      100,
      10,
      10
      );