* Replaces the image head of a JPEG blob with the given one. * Returns a Promise or calls the callback with the new Blob. * * @param {Blob} blob Blob object * @param {ArrayBuffer} head New JPEG head * @param {Function} [callback] Callback function * @returns {Promise |und
(blob, head, callback)
| 208 | * @returns {Promise<Blob|null>|undefined} Combined Blob |
| 209 | */ |
| 210 | function replaceHead(blob, head, callback) { |
| 211 | var options = { maxMetaDataSize: 1024, disableMetaDataParsers: true } |
| 212 | if (!callback && global.Promise) { |
| 213 | return parseMetaData(blob, options).then(function (data) { |
| 214 | return replaceJPEGHead(blob, data.imageHead, head) |
| 215 | }) |
| 216 | } |
| 217 | parseMetaData( |
| 218 | blob, |
| 219 | function (data) { |
| 220 | callback(replaceJPEGHead(blob, data.imageHead, head)) |
| 221 | }, |
| 222 | options |
| 223 | ) |
| 224 | } |
| 225 | |
| 226 | loadImage.transform = function (img, options, callback, file, data) { |
| 227 | if (loadImage.requiresMetaData(options)) { |
nothing calls this directly
no test coverage detected