@@ -5,6 +5,30 @@ const moduleMapper = isBrowser && window.cordova && window.cordova.require && wi
55export const CustomFile = isBrowser && ( ( moduleMapper && moduleMapper . getOriginalSymbol ( window , 'File' ) ) || File )
66export const CustomFileReader = isBrowser && ( ( moduleMapper && moduleMapper . getOriginalSymbol ( window , 'FileReader' ) ) || FileReader )
77
8+ // Check if browser supports automatic image orientation
9+ // see https://github.com/blueimp/JavaScript-Load-Image/blob/1e4df707821a0afcc11ea0720ee403b8759f3881/js/load-image-orientation.js#L37-L53
10+ export const isAutoOrientationInBrowser = ( async ( ) => {
11+ // black 2x1 JPEG, with the following meta information set:
12+ // EXIF Orientation: 6 (Rotated 90° CCW)
13+ const testImageURL =
14+ 'data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAA' +
15+ 'AAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBA' +
16+ 'QEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE' +
17+ 'BAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAEAAgMBEQACEQEDEQH/x' +
18+ 'ABKAAEAAAAAAAAAAAAAAAAAAAALEAEAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAAAAAAA' +
19+ 'AAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwA/8H//2Q=='
20+ const testImageFile = await getFilefromDataUrl ( testImageURL , 'tmp.jpg' , Date . now ( ) )
21+
22+ const testImageCanvas = ( await drawFileInCanvas ( testImageFile ) ) [ 1 ]
23+ const testImageFile2 = await canvasToFile ( testImageCanvas , 'image/jpeg' , 'test.jpg' , Date . now ( ) )
24+ cleanupCanvasMemory ( testImageCanvas )
25+ const testImageURL2 = await getDataUrlFromFile ( testImageFile2 )
26+ const img = await loadImage ( testImageURL2 )
27+ // console.log('img', img.width, img.height)
28+
29+ return img . width === 1 && img . height === 2
30+ } ) ( )
31+
832/**
933 * getDataUrlFromFile
1034 *
0 commit comments