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

    Function getImageDataFromClipboard

    • Extracts ImageData from a clipboard event if an image is present.

      This function iterates through the DataTransferItemList to find the first item with an image MIME type and decodes it.

      Parameters

      • clipboardEvent: ClipboardEvent

        The event object from a paste listener.

      Returns Promise<ImageData | null>

      A promise resolving to ImageData, or null if no image was found in the clipboard.

      window.addEventListener('paste', async (event) => {
      const data = await getImageDataFromClipboard(event)
      if (data) {
      console.log('Pasted image dimensions:', data.width, data.height)
      }
      });