|
55 | 55 | } |
56 | 56 | } |
57 | 57 |
|
58 | | - // Parses image metadata and calls the callback with an object argument |
59 | | - // with the following properties: |
60 | | - // * imageHead: The complete image head as ArrayBuffer (Uint8Array for IE10) |
61 | | - // The options argument accepts an object and supports the following |
62 | | - // properties: |
63 | | - // * maxMetaDataSize: Defines the maximum number of bytes to parse. |
64 | | - // * disableImageHead: Disables creating the imageHead property. |
65 | | - loadImage.parseMetaData = function (file, callback, options, data) { |
| 58 | + /** |
| 59 | + * Parses image metadata and calls the callback with an object argument |
| 60 | + * with the following property: |
| 61 | + * - imageHead: The complete image head as ArrayBuffer |
| 62 | + * The options argument accepts an object and supports the following |
| 63 | + * properties: |
| 64 | + * - maxMetaDataSize: Defines the maximum number of bytes to parse. |
| 65 | + * - disableImageHead: Disables creating the imageHead property. |
| 66 | + * |
| 67 | + * @param {Blob} file Blob object |
| 68 | + * @param {Function} callback Callback fynction |
| 69 | + * @param {object} [options] Parsing options |
| 70 | + * @param {object} [data] Result data object |
| 71 | + * @returns {Promise|undefined} Returns Promise if no callback is provided. |
| 72 | + */ |
| 73 | + function parseMetaData(file, callback, options, data) { |
66 | 74 | var that = this |
67 | 75 | /** |
68 | 76 | * Promise executor |
|
197 | 205 | loadImage.replaceHead = function (blob, head, callback) { |
198 | 206 | var options = { maxMetaDataSize: 256, disableMetaDataParsers: true } |
199 | 207 | if (!callback && loadImage.global.Promise) { |
200 | | - return loadImage.parseMetaData(blob, options).then(function (data) { |
| 208 | + return parseMetaData(blob, options).then(function (data) { |
201 | 209 | return replaceJPEGHead(blob, data.imageHead, head) |
202 | 210 | }) |
203 | 211 | } |
204 | | - loadImage.parseMetaData( |
| 212 | + parseMetaData( |
205 | 213 | blob, |
206 | 214 | function (data) { |
207 | 215 | callback(replaceJPEGHead(blob, data.imageHead, head)) |
|
214 | 222 | loadImage.transform = function (img, options, callback, file, data) { |
215 | 223 | if (loadImage.requiresMetaData(options)) { |
216 | 224 | data = data || {} // eslint-disable-line no-param-reassign |
217 | | - loadImage.parseMetaData( |
| 225 | + parseMetaData( |
218 | 226 | file, |
219 | 227 | function (result) { |
220 | 228 | if (result !== data) { |
|
238 | 246 | originalTransform.apply(loadImage, arguments) |
239 | 247 | } |
240 | 248 | } |
| 249 | + |
| 250 | + loadImage.parseMetaData = parseMetaData |
241 | 251 | }) |
0 commit comments