|
28 | 28 | }(function (loadImage) { |
29 | 29 | 'use strict'; |
30 | 30 |
|
31 | | - loadImage.blobSlice = function () { |
| 31 | + var hasblobSlice = window.Blob && (Blob.prototype.slice || |
| 32 | + Blob.prototype.webkitSlice || Blob.prototype.mozSlice); |
| 33 | + |
| 34 | + loadImage.blobSlice = hasblobSlice && function () { |
32 | 35 | var slice = this.slice || this.webkitSlice || this.mozSlice; |
33 | 36 | return slice.apply(this, arguments); |
34 | 37 | }; |
|
48 | 51 | options = options || {}; |
49 | 52 | var that = this, |
50 | 53 | data = {}, |
51 | | - noMetaData = !window.DataView || !file || file.size < 12 || |
52 | | - file.type !== 'image/jpeg'; |
| 54 | + noMetaData = !(window.DataView && file && file.size >= 12 && |
| 55 | + file.type === 'image/jpeg' && loadImage.blobSlice); |
53 | 56 | if (noMetaData || !loadImage.readFile( |
54 | 57 | // 128 KiB should contain all EXIF/ICC/IPTC segments: |
55 | 58 | loadImage.blobSlice.call(file, 0, 131072), |
|
77 | 80 | if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || |
78 | 81 | markerBytes === 0xfffe) { |
79 | 82 | // The marker bytes (2) are always followed by |
80 | | - // the length bytes, indicating the length of the |
81 | | - // marker segment, which include the length bytes, |
| 83 | + // the length bytes (2), indicating the length of the |
| 84 | + // marker segment, which includes the length bytes, |
82 | 85 | // but not the marker bytes, so we add 2: |
83 | | - markerLength = dataView.getUint16(offset + 2); |
| 86 | + markerLength = dataView.getUint16(offset + 2) + 2; |
84 | 87 | if (offset + markerLength > dataView.byteLength) { |
85 | 88 | console.log('Invalid meta data: Invalid segment size.'); |
86 | 89 | continue; |
|
98 | 101 | ); |
99 | 102 | } |
100 | 103 | } |
101 | | - offset += markerLength + 2; |
| 104 | + offset += markerLength; |
102 | 105 | headLength = offset; |
103 | 106 | } else { |
104 | 107 | // Not an APPn or COM marker, probably safe to |
|
0 commit comments