rasterExport = (
  imgType = 'PNG',
  quality = 1.0,
  windowName = 'Exported Image',
  opts = {}
) => {
  return new Promise((resolve, reject) => {
    const type = imgType === 'ICO' ? 'BMP' : imgType
    const mimeType = `image/${type.toLowerCase()}`
    const { issues, issueCodes } = getIssues()
    const svgElement = svgCanvas.getSvgContent()

    const svgClone = svgElement.cloneNode(true)

    convertImagesToBase64(svgClone)
      .then(() => {
        const svgData = new XMLSerializer().serializeToString(svgClone)
        const svgBlob = new Blob([svgData], {
          type: 'image/svg+xml;charset=utf-8'
        })
        const url = URL.createObjectURL(svgBlob)

        const canvas = document.createElement('canvas')
        const ctx = canvas.getContext('2d')

        const width = svgElement.clientWidth || svgElement.getAttribute('width')
        const height =
          svgElement.clientHeight || svgElement.getAttribute('height')
        canvas.width = width
        canvas.height = height

        const img = new Image()
        img.onload = () => {
          ctx.drawImage(img, 0, 0, width, height)
          URL.revokeObjectURL(url)

          const datauri = canvas.toDataURL(mimeType, quality)
          let blobUrl

          const onExportComplete = blobUrl => {
            const exportObj = {
              datauri,
              bloburl: blobUrl,
              svg: svgData,
              issues,
              issueCodes,
              type: imgType,
              mimeType,
              quality,
              windowName
            }
            if (!opts.avoidEvent) {
              svgCanvas.call('exported', exportObj)
            }
            resolve(exportObj)
          }

          canvas.toBlob(
            blob => {
              blobUrl = URL.createObjectURL(blob)
              onExportComplete(blobUrl)
            },
            mimeType,
            quality
          )
        }

        img.onerror = err => {
          console.error('Failed to load SVG into image element:', err)
          reject(err)
        }

        img.src = url
      })
      .catch(reject)
  })
}
Generates a raster image (PNG, JPEG, etc.) from the SVG content.
@param {string} [imgType='PNG'] - The image type to generate.
@param {number} [quality=1.0] - The image quality (for JPEG).
@param {string} [windowName='Exported Image'] - The window name.
@param {Object} [opts={}] - Additional options.
@returns {Promise<Object>} Resolves to an object containing export data.