Docs
API Docs

Export to Server

The export event will be called every time the user clicks on the export button. By changing enableDownload to false you can prevent the file download to the device of the user. Afterward you can listen for UIEvent.EXPORT and send the image data to a server.

const editor = new PhotoEditorSDKUI.init({
  export: {
    image: {
      exportType: "data-url", // `image`, `data-url` or `blob`
      enableDownload: false, // boolean, enable or disable the automatic file download
    }
  }
})

editor.on(UIEvent.EXPORT, (result) => {
  // user clicked export
  // result will contain the image as a data-url
})

The export function is an alternative to the export event and can be called at any time. By default the image data will be returned with the export options from the configuration but you can override these by providing arguments to the function.

Setting preventExportEvent to true and enableDownload to false will make the export function fully independent from the export event behaviour and will not download the image to the device of the user.

editor
  .export({
    format: "image/jpeg", // `image/png` or `image/jpeg`
    exportType: "data-url", // `image`, `data-url` or `blob`
    quality: 0.9, // 0.1 - 1.0, defines the quality of jpeg images
    enableDownload: false, // boolean, enable or disable the automatic file download
    preventExportEvent: true, // boolean, enable or disable the UIEvent.EXPORT which is called on every export
  })
  .then((dataURL) => {
    // the data can be sent to a server or handled otherwise from here
  })
  .catch((err) => {
    console.err("An error has occured while exporting ", err);
  });