Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

blueimp-load-image

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blueimp-load-image - npm Package Compare versions

Comparing version 5.0.1 to 5.1.0

2

js/load-image-exif.js

@@ -428,3 +428,3 @@ /*

// Registers the Exif parser for the APP1 JPEG meta data segment:
// Registers the Exif parser for the APP1 JPEG metadata segment:
loadImage.metaDataParsers.jpeg[0xffe1].push(loadImage.parseExifData)

@@ -431,0 +431,0 @@

@@ -12,3 +12,3 @@ /*

/* global define, module, require */
/* global define, module, require, Promise */

@@ -29,4 +29,11 @@ ;(function (factory) {

if (typeof fetch !== 'undefined' && typeof Request !== 'undefined') {
var global = loadImage.global
if (global.fetch && global.Request) {
loadImage.fetchBlob = function (url, callback, options) {
if (global.Promise && typeof callback !== 'function') {
return fetch(new Request(url, callback)).then(function (response) {
return response.blob()
})
}
fetch(new Request(url, options))

@@ -41,28 +48,42 @@ .then(function (response) {

}
} else if (
// Check for XHR2 support:
typeof XMLHttpRequest !== 'undefined' &&
typeof ProgressEvent !== 'undefined'
) {
} else if (global.XMLHttpRequest && global.ProgressEvent) {
// Browser supports XHR Level 2 and XHR responseType blob
loadImage.fetchBlob = function (url, callback, options) {
// eslint-disable-next-line no-param-reassign
options = options || {}
var req = new XMLHttpRequest()
req.open(options.method || 'GET', url)
if (options.headers) {
Object.keys(options.headers).forEach(function (key) {
req.setRequestHeader(key, options.headers[key])
})
/**
* Promise executor
*
* @param {Function} resolve Resolution function
* @param {Function} reject Rejection function
*/
function executor(resolve, reject) {
options = options || {} // eslint-disable-line no-param-reassign
var req = new XMLHttpRequest()
req.open(options.method || 'GET', url)
if (options.headers) {
Object.keys(options.headers).forEach(function (key) {
req.setRequestHeader(key, options.headers[key])
})
}
req.withCredentials = options.credentials === 'include'
req.responseType = 'blob'
req.onload = function () {
resolve(req.response)
}
req.onerror = req.onabort = req.ontimeout = function (err) {
if (resolve === reject) {
// Not using Promises
reject(null, err)
} else {
reject(err)
}
}
req.send(options.body)
}
req.withCredentials = options.credentials === 'include'
req.responseType = 'blob'
req.onload = function () {
callback(req.response)
if (global.Promise && typeof callback !== 'function') {
options = callback // eslint-disable-line no-param-reassign
return new Promise(executor)
}
req.onerror = req.onabort = req.ontimeout = function (err) {
callback(null, err)
}
req.send(options.body)
return executor(callback, callback)
}
}
})

@@ -226,3 +226,3 @@ /*

// Registers this IPTC parser for the APP13 JPEG meta data segment:
// Registers this IPTC parser for the APP13 JPEG metadata segment:
loadImage.metaDataParsers.jpeg[0xffed].push(loadImage.parseIptcData)

@@ -229,0 +229,0 @@

@@ -8,3 +8,3 @@ /*

*
* Image meta data handling implementation
* Image metadata handling implementation
* based on the help and contribution of

@@ -17,3 +17,3 @@ * Achim Stöhr.

/* global define, module, require, DataView, Uint8Array */
/* global define, module, require, Promise, DataView, Uint8Array, ArrayBuffer */

@@ -59,3 +59,3 @@ ;(function (factory) {

// Parses image meta data and calls the callback with an object argument
// Parses image metadata and calls the callback with an object argument
// with the following properties:

@@ -68,47 +68,56 @@ // * imageHead: The complete image head as ArrayBuffer (Uint8Array for IE10)

loadImage.parseMetaData = function (file, callback, options, data) {
// eslint-disable-next-line no-param-reassign
options = options || {}
// eslint-disable-next-line no-param-reassign
data = data || {}
var that = this
// 256 KiB should contain all EXIF/ICC/IPTC segments:
var maxMetaDataSize = options.maxMetaDataSize || 262144
var noMetaData = !(
loadImage.global.DataView &&
file &&
file.size >= 12 &&
file.type === 'image/jpeg' &&
loadImage.blobSlice
)
if (
noMetaData ||
!loadImage.readFile(
loadImage.blobSlice.call(file, 0, maxMetaDataSize),
function (e) {
if (e.target.error) {
// FileReader error
// eslint-disable-next-line no-console
console.log(e.target.error)
callback(data)
return
}
// Note on endianness:
// Since the marker and length bytes in JPEG files are always
// stored in big endian order, we can leave the endian parameter
// of the DataView methods undefined, defaulting to big endian.
var buffer = e.target.result
var dataView = new DataView(buffer)
var offset = 2
var maxOffset = dataView.byteLength - 4
var headLength = offset
var markerBytes
var markerLength
var parsers
var i
// Check for the JPEG marker (0xffd8):
if (dataView.getUint16(0) === 0xffd8) {
/**
* Promise executor
*
* @param {Function} resolve Resolution function
* @param {Function} reject Rejection function
* @returns {undefined} Undefined
*/
function executor(resolve, reject) {
if (
!(
loadImage.global.DataView &&
loadImage.blobSlice &&
file &&
file.size >= 12 &&
file.type === 'image/jpeg'
)
) {
// Nothing to parse
return resolve(data)
}
// 256 KiB should contain all EXIF/ICC/IPTC segments:
var maxMetaDataSize = options.maxMetaDataSize || 262144
if (
!loadImage.readFile(
loadImage.blobSlice.call(file, 0, maxMetaDataSize),
function (e) {
if (e.target.error) {
// FileReader error
return reject(e.target.error)
}
// Note on endianness:
// Since the marker and length bytes in JPEG files are always
// stored in big endian order, we can leave the endian parameter
// of the DataView methods undefined, defaulting to big endian.
var buffer = e.target.result
var dataView = new DataView(buffer)
// Check for the JPEG marker (0xffd8):
if (dataView.getUint16(0) !== 0xffd8) {
return reject(
new Error('Invalid JPEG file: Missing JPEG marker.')
)
}
var offset = 2
var maxOffset = dataView.byteLength - 4
var headLength = offset
var markerBytes
var markerLength
var parsers
var i
while (offset < maxOffset) {
markerBytes = dataView.getUint16(offset)
// Search for APPn (0xffeN) and COM (0xfffe) markers,
// which contain application-specific meta-data like
// which contain application-specific metadata like
// Exif, ICC and IPTC data and text comments:

@@ -126,3 +135,3 @@ if (

// eslint-disable-next-line no-console
console.log('Invalid meta data: Invalid segment size.')
console.log('Invalid JPEG metadata: Invalid segment size.')
break

@@ -147,3 +156,3 @@ }

// Not an APPn or COM marker, probably safe to
// assume that this is the end of the meta data
// assume that this is the end of the metadata
break

@@ -157,29 +166,51 @@ }

}
} else {
// eslint-disable-next-line no-console
console.log('Invalid JPEG file: Missing JPEG marker.')
}
callback(data)
},
'readAsArrayBuffer'
)
) {
callback(data)
resolve(data)
},
'readAsArrayBuffer'
)
) {
// No support for the FileReader interface, nothing to parse
resolve(data)
}
}
options = options || {} // eslint-disable-line no-param-reassign
if (loadImage.global.Promise && typeof callback !== 'function') {
options = callback || {} // eslint-disable-line no-param-reassign
data = options // eslint-disable-line no-param-reassign
return new Promise(executor)
}
data = data || {} // eslint-disable-line no-param-reassign
return executor(callback, callback)
}
/**
* Replaces the head of a JPEG Blob
*
* @param {Blob} blob Resolution function
* @param {ArrayBuffer} oldHead Old JPEG head
* @param {ArrayBuffer} newHead New JPEG head
* @returns {Blob} Combined Blob
*/
function replaceJPEGHead(blob, oldHead, newHead) {
return new Blob(
[newHead, loadImage.blobSlice.call(blob, oldHead.byteLength)],
{ type: 'image/jpeg' }
)
}
// Replaces the image head of a JPEG blob with the given one.
// Calls the callback with the new Blob:
// Returns a Promise or calls the callback with the new Blob:
loadImage.replaceHead = function (blob, head, callback) {
var options = { maxMetaDataSize: 256, disableMetaDataParsers: true }
if (!callback && loadImage.global.Promise) {
return loadImage.parseMetaData(blob, options).then(function (data) {
return replaceJPEGHead(blob, data.imageHead, head)
})
}
loadImage.parseMetaData(
blob,
function (data) {
callback(
new Blob(
[head, loadImage.blobSlice.call(blob, data.imageHead.byteLength)],
{ type: 'image/jpeg' }
)
)
callback(replaceJPEGHead(blob, data.imageHead, head))
},
{ maxMetaDataSize: 256, disableMetaDataParsers: true }
options
)

@@ -191,6 +222,19 @@ }

if (loadImage.requiresMetaData(options)) {
data = data || {} // eslint-disable-line no-param-reassign
loadImage.parseMetaData(
file,
function (data) {
originalTransform.call(loadImage, img, options, callback, file, data)
function (result) {
if (result !== data) {
// eslint-disable-next-line no-console
if (loadImage.global.console) console.log(result)
result = data // eslint-disable-line no-param-reassign
}
originalTransform.call(
loadImage,
img,
options,
callback,
file,
result
)
},

@@ -197,0 +241,0 @@ options,

@@ -110,3 +110,3 @@ /*

* @param {object} [options] Options object
* @param {boolean} [withMetaData] Is meta data required for orientation
* @param {boolean} [withMetaData] Is metadata required for orientation
* @returns {boolean} Returns true if orientation requires canvas/meta

@@ -191,3 +191,3 @@ */

// Determines if meta data should be loaded automatically:
// Determines if metadata should be loaded automatically:
loadImage.requiresMetaData = function (options) {

@@ -194,0 +194,0 @@ return (

@@ -1,2 +0,2 @@

!function(n){"use strict";function s(i,a,n){var r,o=document.createElement("img");function e(e,t){t&&console.log(t),e&&s.isInstanceOf("Blob",e)?(i=e,r=s.createObjectURL(i)):(r=i,n&&n.crossOrigin&&(o.crossOrigin=n.crossOrigin)),o.src=r}return o.onerror=function(e){return s.onerror(o,e,i,r,a,n)},o.onload=function(e){return s.onload(o,e,i,r,a,n)},"string"==typeof i?(s.requiresMetaData(n)?s.fetchBlob(i,e,n):e(),o):s.isInstanceOf("Blob",i)||s.isInstanceOf("File",i)?(r=s.createObjectURL(i))?(o.src=r,o):s.readFile(i,function(e){var t=e.target;t&&t.result?o.src=t.result:a&&a(e)}):void 0}var t=n.createObjectURL&&n||n.URL&&URL.revokeObjectURL&&URL||n.webkitURL&&webkitURL;function o(e,t){!e||"blob:"!==e.slice(0,5)||t&&t.noRevoke||s.revokeObjectURL(e)}s.requiresMetaData=function(e){return e&&e.meta},s.fetchBlob=function(e,t){t()},s.isInstanceOf=function(e,t){return Object.prototype.toString.call(t)==="[object "+e+"]"},s.transform=function(e,t,i,a,n){i(e,n)},s.onerror=function(e,t,i,a,n,r){o(a,r),n&&n.call(e,t)},s.onload=function(e,t,i,a,n,r){o(a,r),n&&s.transform(e,r,n,i,{originalWidth:e.naturalWidth||e.width,originalHeight:e.naturalHeight||e.height})},s.createObjectURL=function(e){return!!t&&t.createObjectURL(e)},s.revokeObjectURL=function(e){return!!t&&t.revokeObjectURL(e)},s.readFile=function(e,t,i){if(n.FileReader){var a=new FileReader;if(a.onload=a.onerror=t,a[i=i||"readAsDataURL"])return a[i](e),a}return!1},s.global=n,"function"==typeof define&&define.amd?define(function(){return s}):"object"==typeof module&&module.exports?module.exports=s:n.loadImage=s}("undefined"!=typeof window&&window||this),function(e){"use strict";"function"==typeof define&&define.amd?define(["./load-image"],e):"object"==typeof module&&module.exports?e(require("./load-image")):e(window.loadImage)}(function(x){"use strict";var r=x.transform;x.createCanvas=function(e,t,i){if(i&&x.global.OffscreenCanvas)return new OffscreenCanvas(e,t);var a=document.createElement("canvas");return a.width=e,a.height=t,a},x.transform=function(e,t,i,a,n){r.call(x,x.scale(e,t,n),t,i,a,n)},x.transformCoordinates=function(){},x.getTransformedOptions=function(e,t){var i,a,n,r,o=t.aspectRatio;if(!o)return t;for(a in i={},t)Object.prototype.hasOwnProperty.call(t,a)&&(i[a]=t[a]);return i.crop=!0,o<(n=e.naturalWidth||e.width)/(r=e.naturalHeight||e.height)?(i.maxWidth=r*o,i.maxHeight=r):(i.maxWidth=n,i.maxHeight=n/o),i},x.drawImage=function(e,t,i,a,n,r,o,s,l){var c=t.getContext("2d");return!1===l.imageSmoothingEnabled?(c.msImageSmoothingEnabled=!1,c.imageSmoothingEnabled=!1):l.imageSmoothingQuality&&(c.imageSmoothingQuality=l.imageSmoothingQuality),c.drawImage(e,i,a,n,r,0,0,o,s),c},x.requiresCanvas=function(e){return e.canvas||e.crop||!!e.aspectRatio},x.scale=function(e,t,i){t=t||{},i=i||{};var a,n,r,o,s,l,c,f,u,d,g,m,h=e.getContext||x.requiresCanvas(t)&&!!x.global.HTMLCanvasElement,p=e.naturalWidth||e.width,A=e.naturalHeight||e.height,b=p,S=A;function y(){var e=Math.max((r||b)/b,(o||S)/S);1<e&&(b*=e,S*=e)}function v(){var e=Math.min((a||b)/b,(n||S)/S);e<1&&(b*=e,S*=e)}if(h&&(c=(t=x.getTransformedOptions(e,t,i)).left||0,f=t.top||0,t.sourceWidth?(s=t.sourceWidth,void 0!==t.right&&void 0===t.left&&(c=p-s-t.right)):s=p-c-(t.right||0),t.sourceHeight?(l=t.sourceHeight,void 0!==t.bottom&&void 0===t.top&&(f=A-l-t.bottom)):l=A-f-(t.bottom||0),b=s,S=l),a=t.maxWidth,n=t.maxHeight,r=t.minWidth,o=t.minHeight,h&&a&&n&&t.crop?(g=s/l-(b=a)/(S=n))<0?(l=n*s/a,void 0===t.top&&void 0===t.bottom&&(f=(A-l)/2)):0<g&&(s=a*l/n,void 0===t.left&&void 0===t.right&&(c=(p-s)/2)):((t.contain||t.cover)&&(r=a=a||r,o=n=n||o),t.cover?(v(),y()):(y(),v())),h){if(1<(u=t.pixelRatio)&&parseInt(e.style.width,10)!==p/u&&(b*=u,S*=u),x.orientationCropBug&&!e.getContext&&(c||f||s!==p||l!==A)&&(g=e,e=x.createCanvas(p,A,!0),x.drawImage(g,e,0,0,p,A,p,A,t)),0<(d=t.downsamplingRatio)&&d<1&&b<s&&S<l)for(;b<s*d;)m=x.createCanvas(s*d,l*d,!0),x.drawImage(e,m,c,f,s,l,m.width,m.height,t),f=c=0,s=m.width,l=m.height,e=m;return m=x.createCanvas(b,S),x.transformCoordinates(m,t,i),1<u&&(m.style.width=m.width/u+"px",m.style.height=m.height/u+"px"),x.drawImage(e,m,c,f,s,l,b,S,t).setTransform(1,0,0,1,0,0),m}return e.width=b,e.height=S,e}}),function(e){"use strict";"function"==typeof define&&define.amd?define(["./load-image"],e):"object"==typeof module&&module.exports?e(require("./load-image")):e(window.loadImage)}(function(m){"use strict";m.blobSlice=m.global.Blob&&(Blob.prototype.slice||Blob.prototype.webkitSlice||Blob.prototype.mozSlice),m.bufferSlice=m.global.ArrayBuffer.prototype.slice||function(e,t){t=t||this.byteLength-e;var i=new Uint8Array(this,e,t),a=new Uint8Array(t);return a.set(i),a.buffer},m.metaDataParsers={jpeg:{65505:[],65517:[]}},m.parseMetaData=function(e,f,u,d){d=d||{};var g=this,t=(u=u||{}).maxMetaDataSize||262144;!!(m.global.DataView&&e&&12<=e.size&&"image/jpeg"===e.type&&m.blobSlice)&&m.readFile(m.blobSlice.call(e,0,t),function(e){if(e.target.error)return console.log(e.target.error),void f(d);var t,i,a,n,r=e.target.result,o=new DataView(r),s=2,l=o.byteLength-4,c=s;if(65496===o.getUint16(0)){for(;s<l&&(65504<=(t=o.getUint16(s))&&t<=65519||65534===t);){if(s+(i=o.getUint16(s+2)+2)>o.byteLength){console.log("Invalid meta data: Invalid segment size.");break}if((a=m.metaDataParsers.jpeg[t])&&!u.disableMetaDataParsers)for(n=0;n<a.length;n+=1)a[n].call(g,o,s,i,d,u);c=s+=i}!u.disableImageHead&&6<c&&(d.imageHead=m.bufferSlice.call(r,0,c))}else console.log("Invalid JPEG file: Missing JPEG marker.");f(d)},"readAsArrayBuffer")||f(d)},m.replaceHead=function(t,i,a){m.parseMetaData(t,function(e){a(new Blob([i,m.blobSlice.call(t,e.imageHead.byteLength)],{type:"image/jpeg"}))},{maxMetaDataSize:256,disableMetaDataParsers:!0})};var r=m.transform;m.transform=function(t,i,a,n,e){m.requiresMetaData(i)?m.parseMetaData(n,function(e){r.call(m,t,i,a,n,e)},i,e):r.apply(m,arguments)}}),function(e){"use strict";"function"==typeof define&&define.amd?define(["./load-image"],e):"object"==typeof module&&module.exports?e(require("./load-image")):e(window.loadImage)}(function(e){"use strict";"undefined"!=typeof fetch&&"undefined"!=typeof Request?e.fetchBlob=function(e,t,i){fetch(new Request(e,i)).then(function(e){return e.blob()}).then(t).catch(function(e){t(null,e)})}:"undefined"!=typeof XMLHttpRequest&&"undefined"!=typeof ProgressEvent&&(e.fetchBlob=function(e,t,i){i=i||{};var a=new XMLHttpRequest;a.open(i.method||"GET",e),i.headers&&Object.keys(i.headers).forEach(function(e){a.setRequestHeader(e,i.headers[e])}),a.withCredentials="include"===i.credentials,a.responseType="blob",a.onload=function(){t(a.response)},a.onerror=a.onabort=a.ontimeout=function(e){t(null,e)},a.send(i.body)})}),function(e){"use strict";"function"==typeof define&&define.amd?define(["./load-image","./load-image-scale","./load-image-meta"],e):"object"==typeof module&&module.exports?e(require("./load-image"),require("./load-image-scale"),require("./load-image-meta")):e(window.loadImage)}(function(h){"use strict";var n=h.transform,t=h.requiresCanvas,i=h.requiresMetaData,f=h.transformCoordinates,p=h.getTransformedOptions;function a(e,t){var i=e&&e.orientation;return!0===i&&!h.orientation||1===i&&h.orientation||(!t||h.orientation)&&1<i&&i<9}function A(e,t){return e!==t&&(1===e&&1<t&&t<9||1<e&&e<9)}function b(e,t){if(1<t&&t<9)switch(e){case 2:case 4:return 4<t;case 5:case 7:return t%2==0;case 6:case 8:return 2===t||4===t||5===t||7===t}}!function(t){if(t.global.document){var i=document.createElement("img");i.onload=function(){if(t.orientation=2===i.width&&3===i.height,t.orientation){var e=t.createCanvas(1,1,!0).getContext("2d");e.drawImage(i,1,1,1,1,0,0,1,1),t.orientationCropBug="255,255,255,255"!==e.getImageData(0,0,1,1).data.toString()}},i.src="data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k="}}(h),h.requiresCanvas=function(e){return a(e)||t.call(h,e)},h.requiresMetaData=function(e){return a(e,!0)||i.call(h,e)},h.transform=function(e,t,r,i,a){n.call(h,e,t,function(e,t){if(t){var i=h.orientation&&t.exif&&t.exif.get("Orientation");if(4<i&&i<9){var a=t.originalWidth,n=t.originalHeight;t.originalWidth=n,t.originalHeight=a}}r(e,t)},i,a)},h.getTransformedOptions=function(e,t,i){var a=p.call(h,e,t),n=i.exif&&i.exif.get("Orientation"),r=a.orientation,o=h.orientation&&n;if(!0===r&&(r=n),!A(r,o))return a;var s=a.top,l=a.right,c=a.bottom,f=a.left,u={};for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&(u[d]=a[d]);if((4<(u.orientation=r)&&!(4<o)||r<5&&4<o)&&(u.maxWidth=a.maxHeight,u.maxHeight=a.maxWidth,u.minWidth=a.minHeight,u.minHeight=a.minWidth,u.sourceWidth=a.sourceHeight,u.sourceHeight=a.sourceWidth),1<o){switch(o){case 2:l=a.left,f=a.right;break;case 3:s=a.bottom,l=a.left,c=a.top,f=a.right;break;case 4:s=a.bottom,c=a.top;break;case 5:s=a.left,l=a.bottom,c=a.right,f=a.top;break;case 6:s=a.left,l=a.top,c=a.right,f=a.bottom;break;case 7:s=a.right,l=a.top,c=a.left,f=a.bottom;break;case 8:s=a.right,l=a.bottom,c=a.left,f=a.top}if(b(r,o)){var g=s,m=l;s=c,l=f,c=g,f=m}}switch(u.top=s,u.right=l,u.bottom=c,u.left=f,r){case 2:u.right=f,u.left=l;break;case 3:u.top=c,u.right=f,u.bottom=s,u.left=l;break;case 4:u.top=c,u.bottom=s;break;case 5:u.top=f,u.right=c,u.bottom=l,u.left=s;break;case 6:u.top=l,u.right=c,u.bottom=f,u.left=s;break;case 7:u.top=l,u.right=s,u.bottom=f,u.left=c;break;case 8:u.top=f,u.right=s,u.bottom=l,u.left=c}return u},h.transformCoordinates=function(e,t,i){f.call(h,e,t,i);var a=t.orientation,n=h.orientation&&i.exif&&i.exif.get("Orientation");if(A(a,n)){var r=e.getContext("2d"),o=e.width,s=e.height,l=o,c=s;switch((4<a&&!(4<n)||a<5&&4<n)&&(e.width=s,e.height=o),4<a&&(l=s,c=o),n){case 2:r.translate(l,0),r.scale(-1,1);break;case 3:r.translate(l,c),r.rotate(Math.PI);break;case 4:r.translate(0,c),r.scale(1,-1);break;case 5:r.rotate(-.5*Math.PI),r.scale(-1,1);break;case 6:r.rotate(-.5*Math.PI),r.translate(-l,0);break;case 7:r.rotate(-.5*Math.PI),r.translate(-l,c),r.scale(1,-1);break;case 8:r.rotate(.5*Math.PI),r.translate(0,-c)}switch(b(a,n)&&(r.translate(l,c),r.rotate(Math.PI)),a){case 2:r.translate(o,0),r.scale(-1,1);break;case 3:r.translate(o,s),r.rotate(Math.PI);break;case 4:r.translate(0,s),r.scale(1,-1);break;case 5:r.rotate(.5*Math.PI),r.scale(1,-1);break;case 6:r.rotate(.5*Math.PI),r.translate(0,-s);break;case 7:r.rotate(.5*Math.PI),r.translate(o,-s),r.scale(-1,1);break;case 8:r.rotate(-.5*Math.PI),r.translate(-o,0)}}}}),function(e){"use strict";"function"==typeof define&&define.amd?define(["./load-image","./load-image-meta"],e):"object"==typeof module&&module.exports?e(require("./load-image"),require("./load-image-meta")):e(window.loadImage)}(function(r){"use strict";function h(e){e&&(Object.defineProperty(this,"map",{value:this.ifds[e].map}),Object.defineProperty(this,"tags",{value:this.tags&&this.tags[e]||{}}))}h.prototype.ifds={ifd1:{name:"Thumbnail",map:h.prototype.map={Orientation:274,Thumbnail:"ifd1",Blob:513,Exif:34665,GPSInfo:34853,Interoperability:40965}},34665:{name:"Exif",map:{}},34853:{name:"GPSInfo",map:{}},40965:{name:"Interoperability",map:{}}},h.prototype.get=function(e){return this[e]||this[this.map[e]]};var g={1:{getValue:function(e,t){return e.getUint8(t)},size:1},2:{getValue:function(e,t){return String.fromCharCode(e.getUint8(t))},size:1,ascii:!0},3:{getValue:function(e,t,i){return e.getUint16(t,i)},size:2},4:{getValue:function(e,t,i){return e.getUint32(t,i)},size:4},5:{getValue:function(e,t,i){return e.getUint32(t,i)/e.getUint32(t+4,i)},size:8},9:{getValue:function(e,t,i){return e.getInt32(t,i)},size:4},10:{getValue:function(e,t,i){return e.getInt32(t,i)/e.getInt32(t+4,i)},size:8}};function m(e,t,i,a,n,r){var o,s,l,c,f,u,d=g[a];if(d){if(!((s=4<(o=d.size*n)?t+e.getUint32(i+8,r):i+8)+o>e.byteLength)){if(1===n)return d.getValue(e,s,r);for(l=[],c=0;c<n;c+=1)l[c]=d.getValue(e,s+c*d.size,r);if(d.ascii){for(f="",c=0;c<l.length&&"\0"!==(u=l[c]);c+=1)f+=u;return f}return l}console.log("Invalid Exif data: Invalid data offset.")}else console.log("Invalid Exif data: Invalid tag type.")}function p(e,t,i){return(!e||e[i])&&(!t||!0!==t[i])}function A(e,t,i,a,n,r,o,s){var l,c,f,u,d,g;if(i+6>e.byteLength)console.log("Invalid Exif data: Invalid directory offset.");else{if(!((c=i+2+12*(l=e.getUint16(i,a)))+4>e.byteLength)){for(f=0;f<l;f+=1)u=i+2+12*f,p(o,s,d=e.getUint16(u,a))&&(g=m(e,t,u,e.getUint16(u+2,a),e.getUint32(u+4,a),a),n[d]=g,r&&(r[d]=u));return e.getUint32(c,a)}console.log("Invalid Exif data: Invalid directory size.")}}g[7]=g[1],r.parseExifData=function(c,e,t,f,i){if(!i.disableExif){var u,a,n,d=i.includeExifTags,g=i.excludeExifTags||{34665:{37500:!0}},m=e+10;if(1165519206===c.getUint32(e+4))if(m+8>c.byteLength)console.log("Invalid Exif data: Invalid segment size.");else if(0===c.getUint16(e+8)){switch(c.getUint16(m)){case 18761:u=!0;break;case 19789:u=!1;break;default:return void console.log("Invalid Exif data: Invalid byte alignment marker.")}42===c.getUint16(m+2,u)?(a=c.getUint32(m+4,u),f.exif=new h,i.disableExifOffsets||(f.exifOffsets=new h,f.exifTiffOffset=m,f.exifLittleEndian=u),(a=A(c,m,m+a,u,f.exif,f.exifOffsets,d,g))&&p(d,g,"ifd1")&&(f.exif.ifd1=a,f.exifOffsets&&(f.exifOffsets.ifd1=m+a)),Object.keys(f.exif.ifds).forEach(function(e){var t,i,a,n,r,o,s,l;i=e,a=c,n=m,r=u,o=d,s=g,(l=(t=f).exif[i])&&(t.exif[i]=new h(i),t.exifOffsets&&(t.exifOffsets[i]=new h(i)),A(a,n,n+l,r,t.exif[i],t.exifOffsets&&t.exifOffsets[i],o&&o[i],s&&s[i]))}),(n=f.exif.ifd1)&&n[513]&&n[514]&&(n[513]=function(e,t,i){if(i&&!(t+i>e.byteLength))return new Blob([r.bufferSlice.call(e.buffer,t,t+i)],{type:"image/jpeg"});console.log("Invalid Exif data: Invalid thumbnail data.")}(c,m+n[513],n[514]))):console.log("Invalid Exif data: Missing TIFF marker.")}else console.log("Invalid Exif data: Missing byte alignment offset.")}},r.metaDataParsers.jpeg[65505].push(r.parseExifData),r.exifWriters={274:function(e,t,i){return new DataView(e,t.exifOffsets[274]+8,2).setUint16(0,i,t.exifLittleEndian),e}},r.writeExifData=function(e,t,i,a){r.exifWriters[t.exif.map[i]](e,t,a)},r.ExifMap=h}),function(e){"use strict";"function"==typeof define&&define.amd?define(["./load-image","./load-image-exif"],e):"object"==typeof module&&module.exports?e(require("./load-image"),require("./load-image-exif")):e(window.loadImage)}(function(e){"use strict";var n=e.ExifMap.prototype;n.tags={256:"ImageWidth",257:"ImageHeight",258:"BitsPerSample",259:"Compression",262:"PhotometricInterpretation",274:"Orientation",277:"SamplesPerPixel",284:"PlanarConfiguration",530:"YCbCrSubSampling",531:"YCbCrPositioning",282:"XResolution",283:"YResolution",296:"ResolutionUnit",273:"StripOffsets",278:"RowsPerStrip",279:"StripByteCounts",513:"JPEGInterchangeFormat",514:"JPEGInterchangeFormatLength",301:"TransferFunction",318:"WhitePoint",319:"PrimaryChromaticities",529:"YCbCrCoefficients",532:"ReferenceBlackWhite",306:"DateTime",270:"ImageDescription",271:"Make",272:"Model",305:"Software",315:"Artist",33432:"Copyright",34665:{36864:"ExifVersion",40960:"FlashpixVersion",40961:"ColorSpace",40962:"PixelXDimension",40963:"PixelYDimension",42240:"Gamma",37121:"ComponentsConfiguration",37122:"CompressedBitsPerPixel",37500:"MakerNote",37510:"UserComment",40964:"RelatedSoundFile",36867:"DateTimeOriginal",36868:"DateTimeDigitized",36880:"OffsetTime",36881:"OffsetTimeOriginal",36882:"OffsetTimeDigitized",37520:"SubSecTime",37521:"SubSecTimeOriginal",37522:"SubSecTimeDigitized",33434:"ExposureTime",33437:"FNumber",34850:"ExposureProgram",34852:"SpectralSensitivity",34855:"PhotographicSensitivity",34856:"OECF",34864:"SensitivityType",34865:"StandardOutputSensitivity",34866:"RecommendedExposureIndex",34867:"ISOSpeed",34868:"ISOSpeedLatitudeyyy",34869:"ISOSpeedLatitudezzz",37377:"ShutterSpeedValue",37378:"ApertureValue",37379:"BrightnessValue",37380:"ExposureBias",37381:"MaxApertureValue",37382:"SubjectDistance",37383:"MeteringMode",37384:"LightSource",37385:"Flash",37396:"SubjectArea",37386:"FocalLength",41483:"FlashEnergy",41484:"SpatialFrequencyResponse",41486:"FocalPlaneXResolution",41487:"FocalPlaneYResolution",41488:"FocalPlaneResolutionUnit",41492:"SubjectLocation",41493:"ExposureIndex",41495:"SensingMethod",41728:"FileSource",41729:"SceneType",41730:"CFAPattern",41985:"CustomRendered",41986:"ExposureMode",41987:"WhiteBalance",41988:"DigitalZoomRatio",41989:"FocalLengthIn35mmFilm",41990:"SceneCaptureType",41991:"GainControl",41992:"Contrast",41993:"Saturation",41994:"Sharpness",41995:"DeviceSettingDescription",41996:"SubjectDistanceRange",42016:"ImageUniqueID",42032:"CameraOwnerName",42033:"BodySerialNumber",42034:"LensSpecification",42035:"LensMake",42036:"LensModel",42037:"LensSerialNumber"},34853:{0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude",5:"GPSAltitudeRef",6:"GPSAltitude",7:"GPSTimeStamp",8:"GPSSatellites",9:"GPSStatus",10:"GPSMeasureMode",11:"GPSDOP",12:"GPSSpeedRef",13:"GPSSpeed",14:"GPSTrackRef",15:"GPSTrack",16:"GPSImgDirectionRef",17:"GPSImgDirection",18:"GPSMapDatum",19:"GPSDestLatitudeRef",20:"GPSDestLatitude",21:"GPSDestLongitudeRef",22:"GPSDestLongitude",23:"GPSDestBearingRef",24:"GPSDestBearing",25:"GPSDestDistanceRef",26:"GPSDestDistance",27:"GPSProcessingMethod",28:"GPSAreaInformation",29:"GPSDateStamp",30:"GPSDifferential",31:"GPSHPositioningError"},40965:{1:"InteroperabilityIndex"}},n.tags.ifd1=n.tags,n.stringValues={ExposureProgram:{0:"Undefined",1:"Manual",2:"Normal program",3:"Aperture priority",4:"Shutter priority",5:"Creative program",6:"Action program",7:"Portrait mode",8:"Landscape mode"},MeteringMode:{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"},LightSource:{0:"Unknown",1:"Daylight",2:"Fluorescent",3:"Tungsten (incandescent light)",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 - 5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"},Flash:{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"},SensingMethod:{1:"Undefined",2:"One-chip color area sensor",3:"Two-chip color area sensor",4:"Three-chip color area sensor",5:"Color sequential area sensor",7:"Trilinear sensor",8:"Color sequential linear sensor"},SceneCaptureType:{0:"Standard",1:"Landscape",2:"Portrait",3:"Night scene"},SceneType:{1:"Directly photographed"},CustomRendered:{0:"Normal process",1:"Custom process"},WhiteBalance:{0:"Auto white balance",1:"Manual white balance"},GainControl:{0:"None",1:"Low gain up",2:"High gain up",3:"Low gain down",4:"High gain down"},Contrast:{0:"Normal",1:"Soft",2:"Hard"},Saturation:{0:"Normal",1:"Low saturation",2:"High saturation"},Sharpness:{0:"Normal",1:"Soft",2:"Hard"},SubjectDistanceRange:{0:"Unknown",1:"Macro",2:"Close view",3:"Distant view"},FileSource:{3:"DSC"},ComponentsConfiguration:{0:"",1:"Y",2:"Cb",3:"Cr",4:"R",5:"G",6:"B"},Orientation:{1:"top-left",2:"top-right",3:"bottom-right",4:"bottom-left",5:"left-top",6:"right-top",7:"right-bottom",8:"left-bottom"}},n.getText=function(e){var t=this.get(e);switch(e){case"LightSource":case"Flash":case"MeteringMode":case"ExposureProgram":case"SensingMethod":case"SceneCaptureType":case"SceneType":case"CustomRendered":case"WhiteBalance":case"GainControl":case"Contrast":case"Saturation":case"Sharpness":case"SubjectDistanceRange":case"FileSource":case"Orientation":return this.stringValues[e][t];case"ExifVersion":case"FlashpixVersion":if(!t)return;return String.fromCharCode(t[0],t[1],t[2],t[3]);case"ComponentsConfiguration":if(!t)return;return this.stringValues[e][t[0]]+this.stringValues[e][t[1]]+this.stringValues[e][t[2]]+this.stringValues[e][t[3]];case"GPSVersionID":if(!t)return;return t[0]+"."+t[1]+"."+t[2]+"."+t[3]}return String(t)},n.getAll=function(){var e,t,i,a={};for(e in this)Object.prototype.hasOwnProperty.call(this,e)&&((t=this[e])&&t.getAll?a[this.ifds[e].name]=t.getAll():(i=this.tags[e])&&(a[i]=this.getText(i)));return a},n.getName=function(e){var t=this.tags[e];return"object"==typeof t?this.ifds[e].name:t},function(){var e,t,i,a=n.tags;for(e in a)if(Object.prototype.hasOwnProperty.call(a,e))if(t=n.ifds[e])for(e in i=a[e])Object.prototype.hasOwnProperty.call(i,e)&&(t.map[i[e]]=Number(e));else n.map[a[e]]=Number(e)}()}),function(e){"use strict";"function"==typeof define&&define.amd?define(["./load-image","./load-image-meta"],e):"object"==typeof module&&module.exports?e(require("./load-image"),require("./load-image-meta")):e(window.loadImage)}(function(e){"use strict";function g(){}function m(e,t,i,a,n){return"binary"===t.types[e]?new Blob([i.buffer.slice(a,a+n)]):"Uint16"===t.types[e]?i.getUint16(a):function(e,t,i){for(var a="",n=t+i,r=t;r<n;r+=1)a+=String.fromCharCode(e.getUint8(r));return a}(i,a,n)}function h(e,t,i,a,n,r){for(var o,s,l,c,f,u=t+i,d=t;d<u;)28===e.getUint8(d)&&2===e.getUint8(d+1)&&(l=e.getUint8(d+2),n&&!n[l]||r&&r[l]||(s=e.getInt16(d+3),o=m(l,a.iptc,e,d+5,s),a.iptc[l]=(c=a.iptc[l],f=o,void 0===c?f:c instanceof Array?(c.push(f),c):[c,f]),a.iptcOffsets&&(a.iptcOffsets[l]=d))),d+=1}g.prototype.map={ObjectName:5},g.prototype.types={0:"Uint16",200:"Uint16",201:"Uint16",202:"binary"},g.prototype.get=function(e){return this[e]||this[this.map[e]]},e.parseIptcData=function(e,t,i,a,n){if(!n.disableIptc)for(var r,o,s,l,c=t+i;t+8<c;){if(l=t,943868237===(s=e).getUint32(l)&&1028===s.getUint16(l+4)){var f=(r=t,o=void 0,(o=e.getUint8(r+7))%2!=0&&(o+=1),0===o&&(o=4),o),u=t+8+f;if(c<u){console.log("Invalid IPTC data: Invalid segment offset.");break}var d=e.getUint16(t+6+f);if(c<t+d){console.log("Invalid IPTC data: Invalid segment size.");break}return a.iptc=new g,n.disableIptcOffsets||(a.iptcOffsets=new g),void h(e,u,d,a,n.includeIptcTags,n.excludeIptcTags||{202:!0})}t+=1}},e.metaDataParsers.jpeg[65517].push(e.parseIptcData),e.IptcMap=g}),function(e){"use strict";"function"==typeof define&&define.amd?define(["./load-image","./load-image-iptc"],e):"object"==typeof module&&module.exports?e(require("./load-image"),require("./load-image-iptc")):e(window.loadImage)}(function(e){"use strict";var a=e.IptcMap.prototype;a.tags={0:"ApplicationRecordVersion",3:"ObjectTypeReference",4:"ObjectAttributeReference",5:"ObjectName",7:"EditStatus",8:"EditorialUpdate",10:"Urgency",12:"SubjectReference",15:"Category",20:"SupplementalCategories",22:"FixtureIdentifier",25:"Keywords",26:"ContentLocationCode",27:"ContentLocationName",30:"ReleaseDate",35:"ReleaseTime",37:"ExpirationDate",38:"ExpirationTime",40:"SpecialInstructions",42:"ActionAdvised",45:"ReferenceService",47:"ReferenceDate",50:"ReferenceNumber",55:"DateCreated",60:"TimeCreated",62:"DigitalCreationDate",63:"DigitalCreationTime",65:"OriginatingProgram",70:"ProgramVersion",75:"ObjectCycle",80:"Byline",85:"BylineTitle",90:"City",92:"Sublocation",95:"State",100:"CountryCode",101:"Country",103:"OriginalTransmissionReference",105:"Headline",110:"Credit",115:"Source",116:"CopyrightNotice",118:"Contact",120:"Caption",121:"LocalCaption",122:"Writer",125:"RasterizedCaption",130:"ImageType",131:"ImageOrientation",135:"LanguageIdentifier",150:"AudioType",151:"AudioSamplingRate",152:"AudioSamplingResolution",153:"AudioDuration",154:"AudioOutcue",184:"JobID",185:"MasterDocumentID",186:"ShortDocumentID",187:"UniqueDocumentID",188:"OwnerID",200:"ObjectPreviewFileFormat",201:"ObjectPreviewFileVersion",202:"ObjectPreviewData",221:"Prefs",225:"ClassifyState",228:"SimilarityIndex",230:"DocumentNotes",231:"DocumentHistory",232:"ExifCameraInfo",255:"CatalogSets"},a.stringValues={10:{0:"0 (reserved)",1:"1 (most urgent)",2:"2",3:"3",4:"4",5:"5 (normal urgency)",6:"6",7:"7",8:"8 (least urgent)",9:"9 (user-defined priority)"},75:{a:"Morning",b:"Both Morning and Evening",p:"Evening"},131:{L:"Landscape",P:"Portrait",S:"Square"}},a.getText=function(e){var t=this.get(e),i=this.map[e],a=this.stringValues[i];return a?a[t]:String(t)},a.getAll=function(){var e,t,i={};for(e in this)Object.prototype.hasOwnProperty.call(this,e)&&(t=this.tags[e])&&(i[t]=this.getText(t));return i},a.getName=function(e){return this.tags[e]},function(){var e,t=a.tags,i=a.map||{};for(e in t)Object.prototype.hasOwnProperty.call(t,e)&&(i[t[e]]=Number(e))}()});
!function(c){"use strict";function l(o,e,s){function t(i,a){var n,r=document.createElement("img");function t(e,t){i!==a?((t=t||{}).image=e,i(t)):i&&i(e,t)}function e(e,t){t&&c.console&&console.log(t),e&&l.isInstanceOf("Blob",e)?(o=e,n=l.createObjectURL(o)):(n=o,s&&s.crossOrigin&&(r.crossOrigin=s.crossOrigin)),r.src=n}return r.onerror=function(e){return l.onerror(r,e,o,n,a,s)},r.onload=function(e){return l.onload(r,e,o,n,t,s)},"string"==typeof o?(l.requiresMetaData(s)?l.fetchBlob(o,e,s):e(),r):l.isInstanceOf("Blob",o)||l.isInstanceOf("File",o)?(n=l.createObjectURL(o))?(r.src=n,r):l.readFile(o,function(e){var t=e.target;t&&t.result?r.src=t.result:a&&a(e)}):void 0}return c.Promise&&"function"!=typeof e?(s=e,new Promise(t)):t(e,e)}var t=c.createObjectURL&&c||c.URL&&URL.revokeObjectURL&&URL||c.webkitURL&&webkitURL;function o(e,t){!e||"blob:"!==e.slice(0,5)||t&&t.noRevoke||l.revokeObjectURL(e)}l.requiresMetaData=function(e){return e&&e.meta},l.fetchBlob=function(e,t){t()},l.isInstanceOf=function(e,t){return Object.prototype.toString.call(t)==="[object "+e+"]"},l.transform=function(e,t,i,a,n){i(e,n)},l.onerror=function(e,t,i,a,n,r){o(a,r),n&&n.call(e,t)},l.onload=function(e,t,i,a,n,r){o(a,r),l.transform(e,r,n,i,{originalWidth:e.naturalWidth||e.width,originalHeight:e.naturalHeight||e.height})},l.createObjectURL=function(e){return!!t&&t.createObjectURL(e)},l.revokeObjectURL=function(e){return!!t&&t.revokeObjectURL(e)},l.readFile=function(e,t,i){if(c.FileReader){var a=new FileReader;if(a.onload=a.onerror=t,a[i=i||"readAsDataURL"])return a[i](e),a}return!1},l.global=c,"function"==typeof define&&define.amd?define(function(){return l}):"object"==typeof module&&module.exports?module.exports=l:c.loadImage=l}("undefined"!=typeof window&&window||this),function(e){"use strict";"function"==typeof define&&define.amd?define(["./load-image"],e):"object"==typeof module&&module.exports?e(require("./load-image")):e(window.loadImage)}(function(E){"use strict";var r=E.transform;E.createCanvas=function(e,t,i){if(i&&E.global.OffscreenCanvas)return new OffscreenCanvas(e,t);var a=document.createElement("canvas");return a.width=e,a.height=t,a},E.transform=function(e,t,i,a,n){r.call(E,E.scale(e,t,n),t,i,a,n)},E.transformCoordinates=function(){},E.getTransformedOptions=function(e,t){var i,a,n,r,o=t.aspectRatio;if(!o)return t;for(a in i={},t)Object.prototype.hasOwnProperty.call(t,a)&&(i[a]=t[a]);return i.crop=!0,o<(n=e.naturalWidth||e.width)/(r=e.naturalHeight||e.height)?(i.maxWidth=r*o,i.maxHeight=r):(i.maxWidth=n,i.maxHeight=n/o),i},E.drawImage=function(e,t,i,a,n,r,o,s,c){var l=t.getContext("2d");return!1===c.imageSmoothingEnabled?(l.msImageSmoothingEnabled=!1,l.imageSmoothingEnabled=!1):c.imageSmoothingQuality&&(l.imageSmoothingQuality=c.imageSmoothingQuality),l.drawImage(e,i,a,n,r,0,0,o,s),l},E.requiresCanvas=function(e){return e.canvas||e.crop||!!e.aspectRatio},E.scale=function(e,t,i){t=t||{},i=i||{};var a,n,r,o,s,c,l,f,u,d,g,m,h=e.getContext||E.requiresCanvas(t)&&!!E.global.HTMLCanvasElement,p=e.naturalWidth||e.width,b=e.naturalHeight||e.height,A=p,S=b;function y(){var e=Math.max((r||A)/A,(o||S)/S);1<e&&(A*=e,S*=e)}function v(){var e=Math.min((a||A)/A,(n||S)/S);e<1&&(A*=e,S*=e)}if(h&&(l=(t=E.getTransformedOptions(e,t,i)).left||0,f=t.top||0,t.sourceWidth?(s=t.sourceWidth,void 0!==t.right&&void 0===t.left&&(l=p-s-t.right)):s=p-l-(t.right||0),t.sourceHeight?(c=t.sourceHeight,void 0!==t.bottom&&void 0===t.top&&(f=b-c-t.bottom)):c=b-f-(t.bottom||0),A=s,S=c),a=t.maxWidth,n=t.maxHeight,r=t.minWidth,o=t.minHeight,h&&a&&n&&t.crop?(g=s/c-(A=a)/(S=n))<0?(c=n*s/a,void 0===t.top&&void 0===t.bottom&&(f=(b-c)/2)):0<g&&(s=a*c/n,void 0===t.left&&void 0===t.right&&(l=(p-s)/2)):((t.contain||t.cover)&&(r=a=a||r,o=n=n||o),t.cover?(v(),y()):(y(),v())),h){if(1<(u=t.pixelRatio)&&parseInt(e.style.width,10)!==p/u&&(A*=u,S*=u),E.orientationCropBug&&!e.getContext&&(l||f||s!==p||c!==b)&&(g=e,e=E.createCanvas(p,b,!0),E.drawImage(g,e,0,0,p,b,p,b,t)),0<(d=t.downsamplingRatio)&&d<1&&A<s&&S<c)for(;A<s*d;)m=E.createCanvas(s*d,c*d,!0),E.drawImage(e,m,l,f,s,c,m.width,m.height,t),f=l=0,s=m.width,c=m.height,e=m;return m=E.createCanvas(A,S),E.transformCoordinates(m,t,i),1<u&&(m.style.width=m.width/u+"px",m.style.height=m.height/u+"px"),E.drawImage(e,m,l,f,s,c,A,S,t).setTransform(1,0,0,1,0,0),m}return e.width=A,e.height=S,e}}),function(e){"use strict";"function"==typeof define&&define.amd?define(["./load-image"],e):"object"==typeof module&&module.exports?e(require("./load-image")):e(window.loadImage)}(function(h){"use strict";function n(e,t,i){return new Blob([i,h.blobSlice.call(e,t.byteLength)],{type:"image/jpeg"})}h.blobSlice=h.global.Blob&&(Blob.prototype.slice||Blob.prototype.webkitSlice||Blob.prototype.mozSlice),h.bufferSlice=h.global.ArrayBuffer.prototype.slice||function(e,t){t=t||this.byteLength-e;var i=new Uint8Array(this,e,t),a=new Uint8Array(t);return a.set(i),a.buffer},h.metaDataParsers={jpeg:{65505:[],65517:[]}},h.parseMetaData=function(t,e,d,g){var m=this;function i(f,u){if(!(h.global.DataView&&h.blobSlice&&t&&12<=t.size&&"image/jpeg"===t.type))return f(g);var e=d.maxMetaDataSize||262144;h.readFile(h.blobSlice.call(t,0,e),function(e){if(e.target.error)return u(e.target.error);var t=e.target.result,i=new DataView(t);if(65496!==i.getUint16(0))return u(new Error("Invalid JPEG file: Missing JPEG marker."));for(var a,n,r,o,s=2,c=i.byteLength-4,l=s;s<c&&(65504<=(a=i.getUint16(s))&&a<=65519||65534===a);){if(s+(n=i.getUint16(s+2)+2)>i.byteLength){console.log("Invalid JPEG metadata: Invalid segment size.");break}if((r=h.metaDataParsers.jpeg[a])&&!d.disableMetaDataParsers)for(o=0;o<r.length;o+=1)r[o].call(m,i,s,n,g,d);l=s+=n}!d.disableImageHead&&6<l&&(g.imageHead=h.bufferSlice.call(t,0,l)),f(g)},"readAsArrayBuffer")||f(g)}return d=d||{},h.global.Promise&&"function"!=typeof e?(g=d=e||{},new Promise(i)):(g=g||{},i(e,e))},h.replaceHead=function(t,i,a){var e={maxMetaDataSize:256,disableMetaDataParsers:!0};if(!a&&h.global.Promise)return h.parseMetaData(t,e).then(function(e){return n(t,e.imageHead,i)});h.parseMetaData(t,function(e){a(n(t,e.imageHead,i))},e)};var o=h.transform;h.transform=function(t,i,a,n,r){h.requiresMetaData(i)?(r=r||{},h.parseMetaData(n,function(e){e!==r&&(h.global.console&&console.log(e),e=r),o.call(h,t,i,a,n,e)},i,r)):o.apply(h,arguments)}}),function(e){"use strict";"function"==typeof define&&define.amd?define(["./load-image"],e):"object"==typeof module&&module.exports?e(require("./load-image")):e(window.loadImage)}(function(e){"use strict";var a=e.global;a.fetch&&a.Request?e.fetchBlob=function(e,t,i){if(a.Promise&&"function"!=typeof t)return fetch(new Request(e,t)).then(function(e){return e.blob()});fetch(new Request(e,i)).then(function(e){return e.blob()}).then(t).catch(function(e){t(null,e)})}:a.XMLHttpRequest&&a.ProgressEvent&&(e.fetchBlob=function(e,t,n){function i(t,i){n=n||{};var a=new XMLHttpRequest;a.open(n.method||"GET",e),n.headers&&Object.keys(n.headers).forEach(function(e){a.setRequestHeader(e,n.headers[e])}),a.withCredentials="include"===n.credentials,a.responseType="blob",a.onload=function(){t(a.response)},a.onerror=a.onabort=a.ontimeout=function(e){t===i?i(null,e):i(e)},a.send(n.body)}return a.Promise&&"function"!=typeof t?(n=t,new Promise(i)):i(t,t)})}),function(e){"use strict";"function"==typeof define&&define.amd?define(["./load-image","./load-image-scale","./load-image-meta"],e):"object"==typeof module&&module.exports?e(require("./load-image"),require("./load-image-scale"),require("./load-image-meta")):e(window.loadImage)}(function(h){"use strict";var n=h.transform,t=h.requiresCanvas,i=h.requiresMetaData,f=h.transformCoordinates,p=h.getTransformedOptions;function a(e,t){var i=e&&e.orientation;return!0===i&&!h.orientation||1===i&&h.orientation||(!t||h.orientation)&&1<i&&i<9}function b(e,t){return e!==t&&(1===e&&1<t&&t<9||1<e&&e<9)}function A(e,t){if(1<t&&t<9)switch(e){case 2:case 4:return 4<t;case 5:case 7:return t%2==0;case 6:case 8:return 2===t||4===t||5===t||7===t}}!function(t){if(t.global.document){var i=document.createElement("img");i.onload=function(){if(t.orientation=2===i.width&&3===i.height,t.orientation){var e=t.createCanvas(1,1,!0).getContext("2d");e.drawImage(i,1,1,1,1,0,0,1,1),t.orientationCropBug="255,255,255,255"!==e.getImageData(0,0,1,1).data.toString()}},i.src="data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k="}}(h),h.requiresCanvas=function(e){return a(e)||t.call(h,e)},h.requiresMetaData=function(e){return a(e,!0)||i.call(h,e)},h.transform=function(e,t,r,i,a){n.call(h,e,t,function(e,t){if(t){var i=h.orientation&&t.exif&&t.exif.get("Orientation");if(4<i&&i<9){var a=t.originalWidth,n=t.originalHeight;t.originalWidth=n,t.originalHeight=a}}r(e,t)},i,a)},h.getTransformedOptions=function(e,t,i){var a=p.call(h,e,t),n=i.exif&&i.exif.get("Orientation"),r=a.orientation,o=h.orientation&&n;if(!0===r&&(r=n),!b(r,o))return a;var s=a.top,c=a.right,l=a.bottom,f=a.left,u={};for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&(u[d]=a[d]);if((4<(u.orientation=r)&&!(4<o)||r<5&&4<o)&&(u.maxWidth=a.maxHeight,u.maxHeight=a.maxWidth,u.minWidth=a.minHeight,u.minHeight=a.minWidth,u.sourceWidth=a.sourceHeight,u.sourceHeight=a.sourceWidth),1<o){switch(o){case 2:c=a.left,f=a.right;break;case 3:s=a.bottom,c=a.left,l=a.top,f=a.right;break;case 4:s=a.bottom,l=a.top;break;case 5:s=a.left,c=a.bottom,l=a.right,f=a.top;break;case 6:s=a.left,c=a.top,l=a.right,f=a.bottom;break;case 7:s=a.right,c=a.top,l=a.left,f=a.bottom;break;case 8:s=a.right,c=a.bottom,l=a.left,f=a.top}if(A(r,o)){var g=s,m=c;s=l,c=f,l=g,f=m}}switch(u.top=s,u.right=c,u.bottom=l,u.left=f,r){case 2:u.right=f,u.left=c;break;case 3:u.top=l,u.right=f,u.bottom=s,u.left=c;break;case 4:u.top=l,u.bottom=s;break;case 5:u.top=f,u.right=l,u.bottom=c,u.left=s;break;case 6:u.top=c,u.right=l,u.bottom=f,u.left=s;break;case 7:u.top=c,u.right=s,u.bottom=f,u.left=l;break;case 8:u.top=f,u.right=s,u.bottom=c,u.left=l}return u},h.transformCoordinates=function(e,t,i){f.call(h,e,t,i);var a=t.orientation,n=h.orientation&&i.exif&&i.exif.get("Orientation");if(b(a,n)){var r=e.getContext("2d"),o=e.width,s=e.height,c=o,l=s;switch((4<a&&!(4<n)||a<5&&4<n)&&(e.width=s,e.height=o),4<a&&(c=s,l=o),n){case 2:r.translate(c,0),r.scale(-1,1);break;case 3:r.translate(c,l),r.rotate(Math.PI);break;case 4:r.translate(0,l),r.scale(1,-1);break;case 5:r.rotate(-.5*Math.PI),r.scale(-1,1);break;case 6:r.rotate(-.5*Math.PI),r.translate(-c,0);break;case 7:r.rotate(-.5*Math.PI),r.translate(-c,l),r.scale(1,-1);break;case 8:r.rotate(.5*Math.PI),r.translate(0,-l)}switch(A(a,n)&&(r.translate(c,l),r.rotate(Math.PI)),a){case 2:r.translate(o,0),r.scale(-1,1);break;case 3:r.translate(o,s),r.rotate(Math.PI);break;case 4:r.translate(0,s),r.scale(1,-1);break;case 5:r.rotate(.5*Math.PI),r.scale(1,-1);break;case 6:r.rotate(.5*Math.PI),r.translate(0,-s);break;case 7:r.rotate(.5*Math.PI),r.translate(o,-s),r.scale(-1,1);break;case 8:r.rotate(-.5*Math.PI),r.translate(-o,0)}}}}),function(e){"use strict";"function"==typeof define&&define.amd?define(["./load-image","./load-image-meta"],e):"object"==typeof module&&module.exports?e(require("./load-image"),require("./load-image-meta")):e(window.loadImage)}(function(r){"use strict";function h(e){e&&(Object.defineProperty(this,"map",{value:this.ifds[e].map}),Object.defineProperty(this,"tags",{value:this.tags&&this.tags[e]||{}}))}h.prototype.ifds={ifd1:{name:"Thumbnail",map:h.prototype.map={Orientation:274,Thumbnail:"ifd1",Blob:513,Exif:34665,GPSInfo:34853,Interoperability:40965}},34665:{name:"Exif",map:{}},34853:{name:"GPSInfo",map:{}},40965:{name:"Interoperability",map:{}}},h.prototype.get=function(e){return this[e]||this[this.map[e]]};var g={1:{getValue:function(e,t){return e.getUint8(t)},size:1},2:{getValue:function(e,t){return String.fromCharCode(e.getUint8(t))},size:1,ascii:!0},3:{getValue:function(e,t,i){return e.getUint16(t,i)},size:2},4:{getValue:function(e,t,i){return e.getUint32(t,i)},size:4},5:{getValue:function(e,t,i){return e.getUint32(t,i)/e.getUint32(t+4,i)},size:8},9:{getValue:function(e,t,i){return e.getInt32(t,i)},size:4},10:{getValue:function(e,t,i){return e.getInt32(t,i)/e.getInt32(t+4,i)},size:8}};function m(e,t,i,a,n,r){var o,s,c,l,f,u,d=g[a];if(d){if(!((s=4<(o=d.size*n)?t+e.getUint32(i+8,r):i+8)+o>e.byteLength)){if(1===n)return d.getValue(e,s,r);for(c=[],l=0;l<n;l+=1)c[l]=d.getValue(e,s+l*d.size,r);if(d.ascii){for(f="",l=0;l<c.length&&"\0"!==(u=c[l]);l+=1)f+=u;return f}return c}console.log("Invalid Exif data: Invalid data offset.")}else console.log("Invalid Exif data: Invalid tag type.")}function p(e,t,i){return(!e||e[i])&&(!t||!0!==t[i])}function b(e,t,i,a,n,r,o,s){var c,l,f,u,d,g;if(i+6>e.byteLength)console.log("Invalid Exif data: Invalid directory offset.");else{if(!((l=i+2+12*(c=e.getUint16(i,a)))+4>e.byteLength)){for(f=0;f<c;f+=1)u=i+2+12*f,p(o,s,d=e.getUint16(u,a))&&(g=m(e,t,u,e.getUint16(u+2,a),e.getUint32(u+4,a),a),n[d]=g,r&&(r[d]=u));return e.getUint32(l,a)}console.log("Invalid Exif data: Invalid directory size.")}}g[7]=g[1],r.parseExifData=function(l,e,t,f,i){if(!i.disableExif){var u,a,n,d=i.includeExifTags,g=i.excludeExifTags||{34665:{37500:!0}},m=e+10;if(1165519206===l.getUint32(e+4))if(m+8>l.byteLength)console.log("Invalid Exif data: Invalid segment size.");else if(0===l.getUint16(e+8)){switch(l.getUint16(m)){case 18761:u=!0;break;case 19789:u=!1;break;default:return void console.log("Invalid Exif data: Invalid byte alignment marker.")}42===l.getUint16(m+2,u)?(a=l.getUint32(m+4,u),f.exif=new h,i.disableExifOffsets||(f.exifOffsets=new h,f.exifTiffOffset=m,f.exifLittleEndian=u),(a=b(l,m,m+a,u,f.exif,f.exifOffsets,d,g))&&p(d,g,"ifd1")&&(f.exif.ifd1=a,f.exifOffsets&&(f.exifOffsets.ifd1=m+a)),Object.keys(f.exif.ifds).forEach(function(e){var t,i,a,n,r,o,s,c;i=e,a=l,n=m,r=u,o=d,s=g,(c=(t=f).exif[i])&&(t.exif[i]=new h(i),t.exifOffsets&&(t.exifOffsets[i]=new h(i)),b(a,n,n+c,r,t.exif[i],t.exifOffsets&&t.exifOffsets[i],o&&o[i],s&&s[i]))}),(n=f.exif.ifd1)&&n[513]&&n[514]&&(n[513]=function(e,t,i){if(i&&!(t+i>e.byteLength))return new Blob([r.bufferSlice.call(e.buffer,t,t+i)],{type:"image/jpeg"});console.log("Invalid Exif data: Invalid thumbnail data.")}(l,m+n[513],n[514]))):console.log("Invalid Exif data: Missing TIFF marker.")}else console.log("Invalid Exif data: Missing byte alignment offset.")}},r.metaDataParsers.jpeg[65505].push(r.parseExifData),r.exifWriters={274:function(e,t,i){return new DataView(e,t.exifOffsets[274]+8,2).setUint16(0,i,t.exifLittleEndian),e}},r.writeExifData=function(e,t,i,a){r.exifWriters[t.exif.map[i]](e,t,a)},r.ExifMap=h}),function(e){"use strict";"function"==typeof define&&define.amd?define(["./load-image","./load-image-exif"],e):"object"==typeof module&&module.exports?e(require("./load-image"),require("./load-image-exif")):e(window.loadImage)}(function(e){"use strict";var n=e.ExifMap.prototype;n.tags={256:"ImageWidth",257:"ImageHeight",258:"BitsPerSample",259:"Compression",262:"PhotometricInterpretation",274:"Orientation",277:"SamplesPerPixel",284:"PlanarConfiguration",530:"YCbCrSubSampling",531:"YCbCrPositioning",282:"XResolution",283:"YResolution",296:"ResolutionUnit",273:"StripOffsets",278:"RowsPerStrip",279:"StripByteCounts",513:"JPEGInterchangeFormat",514:"JPEGInterchangeFormatLength",301:"TransferFunction",318:"WhitePoint",319:"PrimaryChromaticities",529:"YCbCrCoefficients",532:"ReferenceBlackWhite",306:"DateTime",270:"ImageDescription",271:"Make",272:"Model",305:"Software",315:"Artist",33432:"Copyright",34665:{36864:"ExifVersion",40960:"FlashpixVersion",40961:"ColorSpace",40962:"PixelXDimension",40963:"PixelYDimension",42240:"Gamma",37121:"ComponentsConfiguration",37122:"CompressedBitsPerPixel",37500:"MakerNote",37510:"UserComment",40964:"RelatedSoundFile",36867:"DateTimeOriginal",36868:"DateTimeDigitized",36880:"OffsetTime",36881:"OffsetTimeOriginal",36882:"OffsetTimeDigitized",37520:"SubSecTime",37521:"SubSecTimeOriginal",37522:"SubSecTimeDigitized",33434:"ExposureTime",33437:"FNumber",34850:"ExposureProgram",34852:"SpectralSensitivity",34855:"PhotographicSensitivity",34856:"OECF",34864:"SensitivityType",34865:"StandardOutputSensitivity",34866:"RecommendedExposureIndex",34867:"ISOSpeed",34868:"ISOSpeedLatitudeyyy",34869:"ISOSpeedLatitudezzz",37377:"ShutterSpeedValue",37378:"ApertureValue",37379:"BrightnessValue",37380:"ExposureBias",37381:"MaxApertureValue",37382:"SubjectDistance",37383:"MeteringMode",37384:"LightSource",37385:"Flash",37396:"SubjectArea",37386:"FocalLength",41483:"FlashEnergy",41484:"SpatialFrequencyResponse",41486:"FocalPlaneXResolution",41487:"FocalPlaneYResolution",41488:"FocalPlaneResolutionUnit",41492:"SubjectLocation",41493:"ExposureIndex",41495:"SensingMethod",41728:"FileSource",41729:"SceneType",41730:"CFAPattern",41985:"CustomRendered",41986:"ExposureMode",41987:"WhiteBalance",41988:"DigitalZoomRatio",41989:"FocalLengthIn35mmFilm",41990:"SceneCaptureType",41991:"GainControl",41992:"Contrast",41993:"Saturation",41994:"Sharpness",41995:"DeviceSettingDescription",41996:"SubjectDistanceRange",42016:"ImageUniqueID",42032:"CameraOwnerName",42033:"BodySerialNumber",42034:"LensSpecification",42035:"LensMake",42036:"LensModel",42037:"LensSerialNumber"},34853:{0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude",5:"GPSAltitudeRef",6:"GPSAltitude",7:"GPSTimeStamp",8:"GPSSatellites",9:"GPSStatus",10:"GPSMeasureMode",11:"GPSDOP",12:"GPSSpeedRef",13:"GPSSpeed",14:"GPSTrackRef",15:"GPSTrack",16:"GPSImgDirectionRef",17:"GPSImgDirection",18:"GPSMapDatum",19:"GPSDestLatitudeRef",20:"GPSDestLatitude",21:"GPSDestLongitudeRef",22:"GPSDestLongitude",23:"GPSDestBearingRef",24:"GPSDestBearing",25:"GPSDestDistanceRef",26:"GPSDestDistance",27:"GPSProcessingMethod",28:"GPSAreaInformation",29:"GPSDateStamp",30:"GPSDifferential",31:"GPSHPositioningError"},40965:{1:"InteroperabilityIndex"}},n.tags.ifd1=n.tags,n.stringValues={ExposureProgram:{0:"Undefined",1:"Manual",2:"Normal program",3:"Aperture priority",4:"Shutter priority",5:"Creative program",6:"Action program",7:"Portrait mode",8:"Landscape mode"},MeteringMode:{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"},LightSource:{0:"Unknown",1:"Daylight",2:"Fluorescent",3:"Tungsten (incandescent light)",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 - 5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"},Flash:{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"},SensingMethod:{1:"Undefined",2:"One-chip color area sensor",3:"Two-chip color area sensor",4:"Three-chip color area sensor",5:"Color sequential area sensor",7:"Trilinear sensor",8:"Color sequential linear sensor"},SceneCaptureType:{0:"Standard",1:"Landscape",2:"Portrait",3:"Night scene"},SceneType:{1:"Directly photographed"},CustomRendered:{0:"Normal process",1:"Custom process"},WhiteBalance:{0:"Auto white balance",1:"Manual white balance"},GainControl:{0:"None",1:"Low gain up",2:"High gain up",3:"Low gain down",4:"High gain down"},Contrast:{0:"Normal",1:"Soft",2:"Hard"},Saturation:{0:"Normal",1:"Low saturation",2:"High saturation"},Sharpness:{0:"Normal",1:"Soft",2:"Hard"},SubjectDistanceRange:{0:"Unknown",1:"Macro",2:"Close view",3:"Distant view"},FileSource:{3:"DSC"},ComponentsConfiguration:{0:"",1:"Y",2:"Cb",3:"Cr",4:"R",5:"G",6:"B"},Orientation:{1:"top-left",2:"top-right",3:"bottom-right",4:"bottom-left",5:"left-top",6:"right-top",7:"right-bottom",8:"left-bottom"}},n.getText=function(e){var t=this.get(e);switch(e){case"LightSource":case"Flash":case"MeteringMode":case"ExposureProgram":case"SensingMethod":case"SceneCaptureType":case"SceneType":case"CustomRendered":case"WhiteBalance":case"GainControl":case"Contrast":case"Saturation":case"Sharpness":case"SubjectDistanceRange":case"FileSource":case"Orientation":return this.stringValues[e][t];case"ExifVersion":case"FlashpixVersion":if(!t)return;return String.fromCharCode(t[0],t[1],t[2],t[3]);case"ComponentsConfiguration":if(!t)return;return this.stringValues[e][t[0]]+this.stringValues[e][t[1]]+this.stringValues[e][t[2]]+this.stringValues[e][t[3]];case"GPSVersionID":if(!t)return;return t[0]+"."+t[1]+"."+t[2]+"."+t[3]}return String(t)},n.getAll=function(){var e,t,i,a={};for(e in this)Object.prototype.hasOwnProperty.call(this,e)&&((t=this[e])&&t.getAll?a[this.ifds[e].name]=t.getAll():(i=this.tags[e])&&(a[i]=this.getText(i)));return a},n.getName=function(e){var t=this.tags[e];return"object"==typeof t?this.ifds[e].name:t},function(){var e,t,i,a=n.tags;for(e in a)if(Object.prototype.hasOwnProperty.call(a,e))if(t=n.ifds[e])for(e in i=a[e])Object.prototype.hasOwnProperty.call(i,e)&&(t.map[i[e]]=Number(e));else n.map[a[e]]=Number(e)}()}),function(e){"use strict";"function"==typeof define&&define.amd?define(["./load-image","./load-image-meta"],e):"object"==typeof module&&module.exports?e(require("./load-image"),require("./load-image-meta")):e(window.loadImage)}(function(e){"use strict";function g(){}function m(e,t,i,a,n){return"binary"===t.types[e]?new Blob([i.buffer.slice(a,a+n)]):"Uint16"===t.types[e]?i.getUint16(a):function(e,t,i){for(var a="",n=t+i,r=t;r<n;r+=1)a+=String.fromCharCode(e.getUint8(r));return a}(i,a,n)}function h(e,t,i,a,n,r){for(var o,s,c,l,f,u=t+i,d=t;d<u;)28===e.getUint8(d)&&2===e.getUint8(d+1)&&(c=e.getUint8(d+2),n&&!n[c]||r&&r[c]||(s=e.getInt16(d+3),o=m(c,a.iptc,e,d+5,s),a.iptc[c]=(l=a.iptc[c],f=o,void 0===l?f:l instanceof Array?(l.push(f),l):[l,f]),a.iptcOffsets&&(a.iptcOffsets[c]=d))),d+=1}g.prototype.map={ObjectName:5},g.prototype.types={0:"Uint16",200:"Uint16",201:"Uint16",202:"binary"},g.prototype.get=function(e){return this[e]||this[this.map[e]]},e.parseIptcData=function(e,t,i,a,n){if(!n.disableIptc)for(var r,o,s,c,l=t+i;t+8<l;){if(c=t,943868237===(s=e).getUint32(c)&&1028===s.getUint16(c+4)){var f=(r=t,o=void 0,(o=e.getUint8(r+7))%2!=0&&(o+=1),0===o&&(o=4),o),u=t+8+f;if(l<u){console.log("Invalid IPTC data: Invalid segment offset.");break}var d=e.getUint16(t+6+f);if(l<t+d){console.log("Invalid IPTC data: Invalid segment size.");break}return a.iptc=new g,n.disableIptcOffsets||(a.iptcOffsets=new g),void h(e,u,d,a,n.includeIptcTags,n.excludeIptcTags||{202:!0})}t+=1}},e.metaDataParsers.jpeg[65517].push(e.parseIptcData),e.IptcMap=g}),function(e){"use strict";"function"==typeof define&&define.amd?define(["./load-image","./load-image-iptc"],e):"object"==typeof module&&module.exports?e(require("./load-image"),require("./load-image-iptc")):e(window.loadImage)}(function(e){"use strict";var a=e.IptcMap.prototype;a.tags={0:"ApplicationRecordVersion",3:"ObjectTypeReference",4:"ObjectAttributeReference",5:"ObjectName",7:"EditStatus",8:"EditorialUpdate",10:"Urgency",12:"SubjectReference",15:"Category",20:"SupplementalCategories",22:"FixtureIdentifier",25:"Keywords",26:"ContentLocationCode",27:"ContentLocationName",30:"ReleaseDate",35:"ReleaseTime",37:"ExpirationDate",38:"ExpirationTime",40:"SpecialInstructions",42:"ActionAdvised",45:"ReferenceService",47:"ReferenceDate",50:"ReferenceNumber",55:"DateCreated",60:"TimeCreated",62:"DigitalCreationDate",63:"DigitalCreationTime",65:"OriginatingProgram",70:"ProgramVersion",75:"ObjectCycle",80:"Byline",85:"BylineTitle",90:"City",92:"Sublocation",95:"State",100:"CountryCode",101:"Country",103:"OriginalTransmissionReference",105:"Headline",110:"Credit",115:"Source",116:"CopyrightNotice",118:"Contact",120:"Caption",121:"LocalCaption",122:"Writer",125:"RasterizedCaption",130:"ImageType",131:"ImageOrientation",135:"LanguageIdentifier",150:"AudioType",151:"AudioSamplingRate",152:"AudioSamplingResolution",153:"AudioDuration",154:"AudioOutcue",184:"JobID",185:"MasterDocumentID",186:"ShortDocumentID",187:"UniqueDocumentID",188:"OwnerID",200:"ObjectPreviewFileFormat",201:"ObjectPreviewFileVersion",202:"ObjectPreviewData",221:"Prefs",225:"ClassifyState",228:"SimilarityIndex",230:"DocumentNotes",231:"DocumentHistory",232:"ExifCameraInfo",255:"CatalogSets"},a.stringValues={10:{0:"0 (reserved)",1:"1 (most urgent)",2:"2",3:"3",4:"4",5:"5 (normal urgency)",6:"6",7:"7",8:"8 (least urgent)",9:"9 (user-defined priority)"},75:{a:"Morning",b:"Both Morning and Evening",p:"Evening"},131:{L:"Landscape",P:"Portrait",S:"Square"}},a.getText=function(e){var t=this.get(e),i=this.map[e],a=this.stringValues[i];return a?a[t]:String(t)},a.getAll=function(){var e,t,i={};for(e in this)Object.prototype.hasOwnProperty.call(this,e)&&(t=this.tags[e])&&(i[t]=this.getText(t));return i},a.getName=function(e){return this.tags[e]},function(){var e,t=a.tags,i=a.map||{};for(e in t)Object.prototype.hasOwnProperty.call(t,e)&&(i[t[e]]=Number(e))}()});
//# sourceMappingURL=load-image.all.min.js.map

@@ -12,3 +12,3 @@ /*

/* global define, webkitURL, module */
/* global define, module, Promise, webkitURL */

@@ -20,66 +20,94 @@ ;(function ($) {

* Loads an image for a given File object.
* Invokes the callback with an img or optional canvas element
* (if supported by the browser) as parameter:.
*
* @param {File|Blob|string} file File or Blob object or image URL
* @param {Function} [callback] Image load event callback
* @param {Function|object} [callback] Image load event callback or options
* @param {object} [options] Options object
* @returns {HTMLImageElement|HTMLCanvasElement|FileReader} image object
* @returns {HTMLImageElement|HTMLCanvasElement|FileReader|Promise} Object
*/
function loadImage(file, callback, options) {
var img = document.createElement('img')
var url
/**
* Callback for the fetchBlob call.
* Promise executor
*
* @param {Blob} blob Blob object
* @param {Error} err Error object
* @param {Function} resolve Resolution function
* @param {Function} reject Rejection function
* @returns {HTMLImageElement|HTMLCanvasElement|FileReader} Object
*/
function fetchBlobCallback(blob, err) {
if (err) console.log(err) // eslint-disable-line no-console
if (blob && loadImage.isInstanceOf('Blob', blob)) {
// eslint-disable-next-line no-param-reassign
file = blob
url = loadImage.createObjectURL(file)
} else {
url = file
if (options && options.crossOrigin) {
img.crossOrigin = options.crossOrigin
function executor(resolve, reject) {
var img = document.createElement('img')
var url
/**
* Callback for the fetchBlob call.
*
* @param {HTMLImageElement|HTMLCanvasElement} img Error object
* @param {object} data Data object
* @returns {undefined} Undefined
*/
function resolveWrapper(img, data) {
if (resolve === reject) {
// Not using Promises
if (resolve) resolve(img, data)
return
}
data = data || {} // eslint-disable-line no-param-reassign
data.image = img
resolve(data)
}
img.src = url
}
img.onerror = function (event) {
return loadImage.onerror(img, event, file, url, callback, options)
}
img.onload = function (event) {
return loadImage.onload(img, event, file, url, callback, options)
}
if (typeof file === 'string') {
if (loadImage.requiresMetaData(options)) {
loadImage.fetchBlob(file, fetchBlobCallback, options)
} else {
fetchBlobCallback()
/**
* Callback for the fetchBlob call.
*
* @param {Blob} blob Blob object
* @param {Error} err Error object
*/
function fetchBlobCallback(blob, err) {
if (err && $.console) console.log(err) // eslint-disable-line no-console
if (blob && loadImage.isInstanceOf('Blob', blob)) {
file = blob // eslint-disable-line no-param-reassign
url = loadImage.createObjectURL(file)
} else {
url = file
if (options && options.crossOrigin) {
img.crossOrigin = options.crossOrigin
}
}
img.src = url
}
return img
} else if (
loadImage.isInstanceOf('Blob', file) ||
// Files are also Blob instances, but some browsers
// (Firefox 3.6) support the File API but not Blobs:
loadImage.isInstanceOf('File', file)
) {
url = loadImage.createObjectURL(file)
if (url) {
img.src = url
img.onerror = function (event) {
return loadImage.onerror(img, event, file, url, reject, options)
}
img.onload = function (event) {
return loadImage.onload(img, event, file, url, resolveWrapper, options)
}
if (typeof file === 'string') {
if (loadImage.requiresMetaData(options)) {
loadImage.fetchBlob(file, fetchBlobCallback, options)
} else {
fetchBlobCallback()
}
return img
} else if (
loadImage.isInstanceOf('Blob', file) ||
// Files are also Blob instances, but some browsers
// (Firefox 3.6) support the File API but not Blobs:
loadImage.isInstanceOf('File', file)
) {
url = loadImage.createObjectURL(file)
if (url) {
img.src = url
return img
}
return loadImage.readFile(file, function (e) {
var target = e.target
if (target && target.result) {
img.src = target.result
} else if (reject) {
reject(e)
}
})
}
return loadImage.readFile(file, function (e) {
var target = e.target
if (target && target.result) {
img.src = target.result
} else if (callback) {
callback(e)
}
})
}
if ($.Promise && typeof callback !== 'function') {
options = callback // eslint-disable-line no-param-reassign
return new Promise(executor)
}
return executor(callback, callback)
}

@@ -105,4 +133,4 @@ // The check for URL.revokeObjectURL fixes an issue with Opera 12,

// Determines if meta data should be loaded automatically.
// Requires the load image meta extension to load meta data.
// Determines if metadata should be loaded automatically.
// Requires the load image meta extension to load metadata.
loadImage.requiresMetaData = function (options) {

@@ -137,8 +165,6 @@ return options && options.meta

revokeHelper(url, options)
if (callback) {
loadImage.transform(img, options, callback, file, {
originalWidth: img.naturalWidth || img.width,
originalHeight: img.naturalHeight || img.height
})
}
loadImage.transform(img, options, callback, file, {
originalWidth: img.naturalWidth || img.width,
originalHeight: img.naturalHeight || img.height
})
}

@@ -145,0 +171,0 @@

{
"name": "blueimp-load-image",
"version": "5.0.1",
"version": "5.1.0",
"title": "JavaScript Load Image",
"description": "JavaScript Load Image is a library to load images provided as File or Blob objects or via URL. It returns an optionally scaled and/or cropped HTML img or canvas element. It also provides methods to parse image meta data to extract IPTC and Exif tags as well as embedded thumbnail images and to restore the complete image header after resizing.",
"description": "JavaScript Load Image is a library to load images provided as File or Blob objects or via URL. It returns an optionally scaled, cropped or rotated HTML img or canvas element. It also provides methods to parse image metadata to extract IPTC and Exif tags as well as embedded thumbnail images, to overwrite the Exif Orientation value and to restore the complete image header after resizing.",
"keywords": [

@@ -16,2 +16,3 @@ "javascript",

"crop",
"rotate",
"img",

@@ -21,5 +22,5 @@ "canvas",

"exif",
"iptc",
"orientation",
"thumbnail",
"resizing"
"iptc"
],

@@ -26,0 +27,0 @@ "homepage": "https://github.com/blueimp/JavaScript-Load-Image",

@@ -7,3 +7,3 @@ # JavaScript Load Image

- [Demo](#demo)
- [Demo](https://blueimp.github.io/JavaScript-Load-Image/)
- [Description](#description)

@@ -16,2 +16,8 @@ - [Setup](#setup)

- [API](#api)
- [Callback](#callback)
- [Function signature](#function-signature)
- [Canceling event handling](#canceling-event-handling)
- [Callback arguments](#callback-arguments)
- [Error handling](#error-handling)
- [Promise](#promise)
- [Options](#options)

@@ -41,3 +47,3 @@ - [maxWidth](#maxwidth)

- [noRevoke](#norevoke)
- [Meta data parsing](#meta-data-parsing)
- [Metadata parsing](#metadata-parsing)
- [Image head](#image-head)

@@ -56,14 +62,14 @@ - [Exif parser](#exif-parser)

## Demo
## Description
[JavaScript Load Image Demo](https://blueimp.github.io/JavaScript-Load-Image/)
JavaScript Load Image is a library to load images provided as `File` or `Blob`
objects or via `URL`. It returns an optionally **scaled**, **cropped** or
**rotated** HTML `img` or `canvas` element.
## Description
It also provides methods to parse image metadata to extract
[IPTC](https://iptc.org/standards/photo-metadata/) and
[Exif](https://en.wikipedia.org/wiki/Exif) tags as well as embedded thumbnail
images, to overwrite the Exif Orientation value and to restore the complete
image header after resizing.
JavaScript Load Image is a library to load images provided as File or Blob
objects or via URL. It returns an optionally scaled and/or cropped HTML img or
canvas element. It also provides methods to parse image meta data to extract
IPTC and Exif tags as well as embedded thumbnail images and to restore the
complete image header after resizing.
## Setup

@@ -119,6 +125,18 @@

Or using the
[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
based API like this:
```js
document.getElementById('file-input').onchange = function (e) {
loadImage(e.target.files[0], { maxWidth: 600 }).then(function (data) {
document.body.appendChild(data.image)
})
}
```
### Image scaling
It is also possible to use the image scaling functionality with an existing
image:
It is also possible to use the image scaling functionality directly with an
existing image:

@@ -134,21 +152,34 @@ ```js

The JavaScript Load Image library has zero dependencies.
The JavaScript Load Image library has zero dependencies, but benefits from the
following two
[polyfills](https://developer.mozilla.org/en-US/docs/Glossary/Polyfill):
However, JavaScript Load Image is a very suitable complement to the
[Canvas to Blob](https://github.com/blueimp/JavaScript-Canvas-to-Blob) library.
- [blueimp-canvas-to-blob](https://github.com/blueimp/JavaScript-Canvas-to-Blob)
for browsers without native
[canvas.toBlob()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)
support, to create `Blob` objects out of transformed `canvas` elements.
- [promise-polyfill](https://github.com/taylorhakes/promise-polyfill) to be able
to use the
[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
based `loadImage` API in Browsers without native `Promise` support.
## API
### Callback
#### Function signature
The `loadImage()` function accepts a
[File](https://developer.mozilla.org/en/DOM/File) or
[Blob](https://developer.mozilla.org/en/DOM/Blob) object or a simple image URL
(e.g. `'https://example.org/image.png'`) as first argument.
[Blob](https://developer.mozilla.org/en/DOM/Blob) object or an image URL as
first argument.
If a [File](https://developer.mozilla.org/en/DOM/File) or
[Blob](https://developer.mozilla.org/en/DOM/Blob) is passed as parameter, it
returns a HTML `img` element if the browser supports the
[URL](https://developer.mozilla.org/en/DOM/window.URL) API or a
[FileReader](https://developer.mozilla.org/en/DOM/FileReader) object if
supported, or `false`.
It always returns a HTML
returns an HTML `img` element if the browser supports the
[URL](https://developer.mozilla.org/en/DOM/window.URL) API, alternatively a
[FileReader](https://developer.mozilla.org/en/DOM/FileReader) object if the
`FileReader` API is supported, or `false`.
It always returns an HTML
[img](https://developer.mozilla.org/en/docs/HTML/Element/Img) element when

@@ -158,50 +189,56 @@ passing an image URL:

```js
document.getElementById('file-input').onchange = function (e) {
var loadingImage = loadImage(
e.target.files[0],
function (img) {
document.body.appendChild(img)
},
{ maxWidth: 600 }
)
if (!loadingImage) {
// Alternative code ...
}
}
var loadingImage = loadImage(
'https://example.org/image.png',
function (img) {
document.body.appendChild(img)
},
{ maxWidth: 600 }
)
```
#### Canceling event handling
The `img` element or
[FileReader](https://developer.mozilla.org/en/DOM/FileReader) object returned by
the `loadImage()` function allows to abort the loading process by setting the
the `loadImage()` function allows to cancel event handling by setting the
`onload` and `onerror` event handlers to null:
```js
document.getElementById('file-input').onchange = function (e) {
var loadingImage = loadImage(
e.target.files[0],
function (img) {
document.body.appendChild(img)
},
{ maxWidth: 600 }
)
loadingImage.onload = loadingImage.onerror = null
}
var loadingImage = loadImage(
'https://example.org/image.png',
function (img) {
document.body.appendChild(img)
},
{ maxWidth: 600 }
)
// Cancel event handling:
loadingImage.onload = loadingImage.onerror = null
```
The second argument must be a `callback` function, which is called when the
image has been loaded or an error occurred while loading the image. The callback
function is passed two arguments.
The first is either an HTML `img` element, a
[canvas](https://developer.mozilla.org/en/HTML/Canvas) element, or an
[Event](https://developer.mozilla.org/en/DOM/event) object of type `error`.
The second is on object with the original image dimensions as properties and
potentially additional [meta data](#meta-data-parsing):
#### Callback arguments
For the callback style API, the second argument to `loadImage()` must be a
`callback` function, which is called when the image has been loaded or an error
occurred while loading the image.
The callback function is passed two arguments:
1. An HTML [img](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img)
element or [canvas](https://developer.mozilla.org/en/HTML/Canvas) element, or
an [Event](https://developer.mozilla.org/en/DOM/event) object of type
`error`.
2. An object with the original image dimensions as properties and potentially
additional [metadata](#metadata-parsing).
#### Error handling
Example code implementing error handling:
```js
var imageUrl = 'https://example.org/image.png'
loadImage(
imageUrl,
fileOrBlobOrUrl,
function (img, data) {
if (img.type === 'error') {
console.error('Error loading image ' + imageUrl)
console.error('Error loading image file')
} else {

@@ -217,7 +254,42 @@ document.body.appendChild(img)

### Promise
If the `loadImage()` function is called without a `callback` function as second
argument and the
[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
API is available, it returns a `Promise` object:
```js
loadImage(fileOrBlobOrUrl, { maxWidth: 600 })
.then(function (data) {
document.body.appendChild(data.image)
console.log('Original image width: ', data.originalWidth)
console.log('Original image height: ', data.originalHeight)
})
.catch(function (err) {
// Handling image loading errors
console.log(err)
})
```
The `Promise` resolves with an object with the following properties:
- `image`: An HTML
[img](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img) or
[canvas](https://developer.mozilla.org/en/HTML/Canvas) element.
- `originalWidth`: The original width of the image.
- `originalHeight`: The original height of the image.
If [metadata](#metadata-parsing) has been parsed, additional properties might be
present on the object.
If image loading fails, the `Promise` rejects with an
[Event](https://developer.mozilla.org/en/DOM/event) object of type `error`.
## Options
The optional third argument to `loadImage()` is a map of options.
The optional options argument to `loadImage()` allows to configure the image
loading.
They can be used the following way:
It can be used the following way using the callback style:

@@ -240,2 +312,16 @@ ```js

Or the following way with the `Promise` based API:
```js
loadImage(fileOrBlobOrUrl, {
maxWidth: 600,
maxHeight: 300,
minWidth: 100,
minHeight: 50,
canvas: true
}).then(function (data) {
document.body.appendChild(data.image)
})
```
All settings are optional. By default, the image is returned as HTML `img`

@@ -246,15 +332,15 @@ element without any image size restrictions.

Defines the maximum width of the img/canvas element.
Defines the maximum width of the `img`/`canvas` element.
### maxHeight
Defines the maximum height of the img/canvas element.
Defines the maximum height of the `img`/`canvas` element.
### minWidth
Defines the minimum width of the img/canvas element.
Defines the minimum width of the `img`/`canvas` element.
### minHeight
Defines the minimum height of the img/canvas element.
Defines the minimum height of the `img`/`canvas` element.

@@ -315,4 +401,5 @@ ### sourceWidth

screen.
Should be set to `window.devicePixelRatio` unless the scaled image is not
rendered on screen.
Should be set to
[window.devicePixelRatio](https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio)
unless the scaled image is not rendered on screen.
Defaults to `1` and requires `canvas: true`.

@@ -322,5 +409,6 @@

Defines the ratio in which the image is downsampled.
By default, images are downsampled in one step. With a ratio of `0.5`, each step
scales the image to half the size, before reaching the target dimensions.
Defines the ratio in which the image is downsampled (scaled down in steps).
By default, images are downsampled in one step.
With a ratio of `0.5`, each step scales the image to half the size, before
reaching the target dimensions.
Requires `canvas: true`.

@@ -343,3 +431,3 @@

Crops the image to the maxWidth/maxHeight constraints if set to `true`.
Crops the image to the `maxWidth`/`maxHeight` constraints if set to `true`.
Enabling the `crop` option also enables the `canvas` option.

@@ -350,5 +438,7 @@

Transform the canvas according to the specified Exif orientation, which can be
an `integer` in the range of `1` to `8` or the boolean value `true`.
an `integer` in the range of `1` to `8` or the boolean value `true`.
When set to `true`, it will set the orientation value based on the EXIF data of
the image, which will be parsed automatically if the exif library is available.
the image, which will be parsed automatically if the Exif extension is
available.

@@ -385,6 +475,8 @@ Exif orientation values to correctly display the letter F:

the browser supports automatic image orientation (see
[browser support for image-orientation](https://caniuse.com/#feat=css-image-orientation)).
[browser support for image-orientation](https://caniuse.com/#feat=css-image-orientation)).
Setting `orientation` to `1` enables the `canvas` and `meta` options if the
browser does support automatic image orientation (to allow reset of the
orientation).
orientation).
Setting `orientation` to an integer in the range of `2` to `8` always enables

@@ -396,10 +488,12 @@ the `canvas` option and also enables the `meta` option if the browser supports

Automatically parses the image meta data if set to `true`.
If meta data has been found, the data object passed as second argument to the
Automatically parses the image metadata if set to `true`.
If metadata has been found, the data object passed as second argument to the
callback function has additional properties (see
[meta data parsing](#meta-data-parsing)).
[metadata parsing](#metadata-parsing)).
If the file is given as URL and the browser supports the
[fetch API](https://developer.mozilla.org/en/docs/Web/API/Fetch_API) or the XHR
[responseType](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseType)
`blob`, fetches the file as Blob to be able to parse the meta data.
`blob`, fetches the file as `Blob` to be able to parse the metadata.

@@ -413,3 +507,3 @@ ### canvas

Sets the crossOrigin property on the img element for loading
Sets the `crossOrigin` property on the `img` element for loading
[CORS enabled images](https://developer.mozilla.org/en-US/docs/HTML/CORS_Enabled_Image).

@@ -424,6 +518,6 @@

## Meta data parsing
## Metadata parsing
If the Load Image Meta extension is included, it is also possible to parse image
meta data automatically with the `meta` option:
If the Load Image Meta extension is included, it is possible to parse image meta
data automatically with the `meta` option:

@@ -459,8 +553,24 @@ ```js

The Meta data extension also adds additional options used for the
`parseMetaData` method:
Or using the
[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
based API:
- `maxMetaDataSize`: Maximum number of bytes of meta data to parse.
```js
loadImage
.parseMetaData(fileOrBlob, {
maxMetaDataSize: 262144
})
.then(function (data) {
console.log('Original image head: ', data.imageHead)
console.log('Exif data: ', data.exif) // requires exif extension
console.log('IPTC data: ', data.iptc) // requires iptc extension
})
```
The Metadata extension adds additional options used for the `parseMetaData`
method:
- `maxMetaDataSize`: Maximum number of bytes of metadata to parse.
- `disableImageHead`: Disable parsing the original image head.
- `disableMetaDataParsers`: Disable parsing meta data (image head only)
- `disableMetaDataParsers`: Disable parsing metadata (image head only)

@@ -471,6 +581,7 @@ ### Image head

`loadImage.replaceHead`, which requires the resized image as `Blob` object as
first argument and an `ArrayBuffer` image head as second argument. The third
argument must be a `callback` function, which is called with the new `Blob`
object:
first argument and an `ArrayBuffer` image head as second argument.
With callback style, the third argument must be a `callback` function, which is
called with the new `Blob` object:
```js

@@ -480,6 +591,6 @@ loadImage(

function (img, data) {
if (data.imageHead && data.exif) {
if (data.imageHead) {
img.toBlob(function (blob) {
loadImage.replaceHead(blob, data.imageHead, function (newBlob) {
// do something with newBlob
// do something with the new Blob object
})

@@ -493,9 +604,36 @@ }, 'image/jpeg')

**Note:**
Blob objects of resized images can be created via
[canvas.toBlob](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob).
For browsers which don't have native support, a
[canvas.toBlob polyfill](https://github.com/blueimp/JavaScript-Canvas-to-Blob)
is available.
Or using the
[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
based API like this:
```js
loadImage(fileOrBlobOrUrl, { meta: true, canvas: true, maxWidth: 800 })
.then(function (data) {
if (!data.imageHead) throw new Error('Could not parse image metadata')
return new Promise(function (resolve) {
data.image.toBlob(function (blob) {
data.blob = blob
resolve(data)
}, 'image/jpeg')
})
})
.then(function (data) {
return loadImage.replaceHead(data.blob, data.imageHead)
})
.then(function (blob) {
// do something with the new Blob object
})
.catch(function (err) {
console.error(err)
})
```
**Please note:**
`Blob` objects of resized images can be created via
[canvas.toBlob](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob).
[blueimp-canvas-to-blob](https://github.com/blueimp/JavaScript-Canvas-to-Blob)
provides a polyfill for browsers without native
[canvas.toBlob](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)
support.
### Exif parser

@@ -529,3 +667,3 @@

- `Orientation`
- `Thumbnail`
- `Thumbnail` (see [Exif Thumbnail](#exif-thumbnail))
- `Exif` (see [Exif IFD](#exif-ifd))

@@ -543,3 +681,3 @@ - `GPSInfo` (see [GPSInfo IFD](#gpsinfo-ifd))

```js
var flashText = data.exif.getText('Orientation') // e.g. right-top for value 6
var orientationText = data.exif.getText('Orientation') // e.g. right-top

@@ -554,3 +692,3 @@ var name = data.exif.getName(0x0112) // Orientation

Example code displaying a thumbnail image embedded into the Exif meta data:
Example code displaying a thumbnail image embedded into the Exif metadata:

@@ -717,2 +855,6 @@ ```js

**Please note:**
The Exif writer relies on the Exif tag offsets being available as
`data.exifOffsets` property.
### IPTC parser

@@ -806,3 +948,3 @@

The JavaScript Load Image script is released under the
The JavaScript Load Image library is released under the
[MIT license](https://opensource.org/licenses/MIT).

@@ -812,6 +954,7 @@

- Image meta data handling implementation based on the help and contribution of
- Original image metadata handling implemented with the help and contribution of
Achim Stöhr.
- Exif tags mapping based on Jacob Seidelin's
- Original Exif tags mapping based on Jacob Seidelin's
[exif-js](https://github.com/jseidelin/exif-js) library.
- IPTC parser implementation by [Dave Bevan](https://github.com/bevand10).
- Original IPTC parser implementation by
[Dave Bevan](https://github.com/bevand10).

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc