removeExifFromImageFile function

Future<String?> removeExifFromImageFile(
  1. File file
)

Removes Exif from JPEG file.

Returns null if no operation was performed.

Implementation

Future<String?> removeExifFromImageFile(File file) async {
  var mimeType = getFileMimeType(file);

  if (mimeType != null && mimeType.isImageJPEG) {
    var fileURL = await readFileDataAsBlobURL(file);

    if (fileURL != null) {
      var img = HTMLImageElement()..src = fileURL;

      await _yeld();

      await elementOnLoad(img);

      await _yeld();

      var canvas = toCanvasElement(img, img.naturalWidth, img.naturalHeight);

      await _yeld();

      revokeBlobURL(fileURL);

      await _yeld();

      var dataUrl = canvas.toDataUrl('image/png', 0.99);

      await _yeld();

      return dataUrl;
    }
  }

  return null;
}