How to use the browser-image-compression.getFilefromDataUrl function in browser-image-compression

To help you get started, we’ve selected a few browser-image-compression examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nerdic-coder / block-photos / src / services / photos-service.ts View on Github external
PhotoType.Thumbnail,
          metadata.type
        );
        await StorageService.setItem(mainId + '-thumbnail', thumbnailData);

        rawPhoto = thumbnailData;
      } else {
        photoType = PhotoType.Download;
      }
    } else if (!rawPhoto && photoType === PhotoType.Viewer) {
      rawPhoto = await StorageService.getItem(mainId, false);
      const { Device } = Plugins;
      const info = await Device.getInfo();
      if (info.model !== 'iPhone' && info.model !== 'iPad') {
        const viewerData = await PhotosService.compressPhoto(
          await imageCompression.getFilefromDataUrl(rawPhoto),
          PhotoType.Viewer,
          metadata.type
        );
        await StorageService.setItem(mainId + '-viewer', viewerData, true);
        rawPhoto = viewerData;
      } else {
        photoType = PhotoType.Download;
      }
    }

    if (!rawPhoto) {
      return false;
    }

    if (rawPhoto && !rawPhoto.match('data:image/.*')) {
      metadata.type