Skip to content

Commit

Permalink
asynchronously load blueimp-load-image
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Besson committed Apr 15, 2021
1 parent 31cdd51 commit d64cb0a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/js/upload-file.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// This file exposes a simple function that upload a file to c2c image backend

import loadImage from 'blueimp-load-image';
import { isValid, formatISO, parse, parseISO } from 'date-fns';

import Worker from '@/js/Worker';
Expand Down Expand Up @@ -140,6 +138,7 @@ const preProcess = async (file, document, orientation, onDataUrlReady) => {

if (Object.keys(options).length) {
options = { ...options, canvas: true };
const loadImage = await import(/* webpackChunkName: "load-image" */ 'blueimp-load-image');
const { image: canvas } = await loadImage(file, options);
onDataUrlReady(canvas.toDataURL(file.type)); // send data url to caller
// and extract modified image for upload
Expand All @@ -165,6 +164,7 @@ const orientations = [1, 6, 3, 8];
const uploadFile = async (file, angle, onDataUrlReady, onUploadProgress, onSuccess, onFailure) => {
try {
const document = {};
const loadImage = await import(/* webpackChunkName: "load-image" */ 'blueimp-load-image');
const metaData = await loadImage.parseMetaData(file);
let orientation = await parseMetaData(document, metaData);
if (angle) {
Expand Down

0 comments on commit d64cb0a

Please sign in to comment.