processImageData = function processImageData(imageData, format, alias, compression) {
    var result, dataAsBinaryString;

    if (typeof imageData === "string" && getImageFileTypeByImageData(imageData) === UNKNOWN) {
      imageData = unescape(imageData);
      var tmpImageData = convertBase64ToBinaryString(imageData, false);

      if (tmpImageData !== "") {
        imageData = tmpImageData;
      } else {
        tmpImageData = jsPDFAPI.loadFile(imageData, true);

        if (tmpImageData !== undefined) {
          imageData = tmpImageData;
        }
      }
    }

    if (isDOMElement(imageData)) {
      imageData = getImageDataFromElement(imageData, format);
    }

    format = getImageFileTypeByImageData(imageData, format);

    if (!isImageTypeSupported(format)) {
      throw new Error("addImage does not support files of type '" + format + "', please ensure that a plugin for '" + format + "' support is added.");
    } // now do the heavy lifting


    if (notDefined(alias)) {
      alias = generateAliasFromImageData(imageData);
    }

    result = checkImagesForAlias.call(this, alias);

    if (!result) {
      if (supportsArrayBuffer()) {
        // no need to convert if imageData is already uint8array
        if (!(imageData instanceof Uint8Array) && format !== "RGBA") {
          dataAsBinaryString = imageData;
          imageData = binaryStringToUint8Array(imageData);
        }
      }

      result = this["process" + format.toUpperCase()](imageData, getImageIndex.call(this), alias, checkCompressValue(compression), dataAsBinaryString);
    }

    if (!result) {
      throw new Error("An unknown error occurred whilst processing the image.");
    }

    return result;
  }
Adds an Image to the PDF.

@name addImage
@public
@function
@param {string|HTMLImageElement|HTMLCanvasElement|Uint8Array|RGBAData} imageData imageData as base64 encoded DataUrl or Image-HTMLElement or Canvas-HTMLElement or object containing RGBA array (like output from canvas.getImageData).
@param {string} format format of file if filetype-recognition fails or in case of a Canvas-Element needs to be specified (default for Canvas is JPEG), e.g. 'JPEG', 'PNG', 'WEBP'
@param {number} x x Coordinate (in units declared at inception of PDF document) against left edge of the page
@param {number} y y Coordinate (in units declared at inception of PDF document) against upper edge of the page
@param {number} width width of the image (in units declared at inception of PDF document)
@param {number} height height of the Image (in units declared at inception of PDF document)
@param {string} alias alias of the image (if used multiple times)
@param {string} compression compression of the generated JPEG, can have the values 'NONE', 'FAST', 'MEDIUM' and 'SLOW'
@param {number} rotation rotation of the image in degrees (0-359)

@returns jsPDF