blueimp-load-image
Advanced tools
Comparing version 3.0.0 to 4.0.0
@@ -99,2 +99,4 @@ /* | ||
var i | ||
var arr1 | ||
var arr2 | ||
// Check for the JPEG marker (0xffd8): | ||
@@ -148,5 +150,8 @@ if (dataView.getUint16(0) === 0xffd8) { | ||
} else { | ||
// Workaround for IE10, which does not yet | ||
// support ArrayBuffer.slice: | ||
data.imageHead = new Uint8Array(buffer).subarray(0, headLength) | ||
// Workaround for IE10, which does not support | ||
// ArrayBuffer.slice: | ||
arr1 = new Uint8Array(buffer, 0, headLength) | ||
arr2 = new Uint8Array(headLength) | ||
arr2.set(arr1) | ||
data.imageHead = arr2.buffer | ||
} | ||
@@ -186,3 +191,3 @@ } | ||
loadImage.transform = function (img, options, callback, file, data) { | ||
if (loadImage.hasMetaOption(options)) { | ||
if (loadImage.requiresMetaData(options)) { | ||
loadImage.parseMetaData( | ||
@@ -189,0 +194,0 @@ file, |
@@ -12,2 +12,31 @@ /* | ||
/* | ||
Exif orientation values to correctly display the letter F: | ||
1 2 | ||
██████ ██████ | ||
██ ██ | ||
████ ████ | ||
██ ██ | ||
██ ██ | ||
3 4 | ||
██ ██ | ||
██ ██ | ||
████ ████ | ||
██ ██ | ||
██████ ██████ | ||
5 6 | ||
██████████ ██ | ||
██ ██ ██ ██ | ||
██ ██████████ | ||
7 8 | ||
██ ██████████ | ||
██ ██ ██ ██ | ||
██████████ ██ | ||
*/ | ||
/* global define, module, require */ | ||
@@ -33,10 +62,14 @@ | ||
var originalHasCanvasOption = loadImage.hasCanvasOption | ||
var originalHasMetaOption = loadImage.hasMetaOption | ||
var originalTransform = loadImage.transform | ||
var originalRequiresCanvas = loadImage.requiresCanvas | ||
var originalRequiresMetaData = loadImage.requiresMetaData | ||
var originalTransformCoordinates = loadImage.transformCoordinates | ||
var originalGetTransformedOptions = loadImage.getTransformedOptions | ||
;(function () { | ||
// black 2x1 JPEG, with the following meta information set: | ||
;(function ($) { | ||
// black+white 3x2 JPEG, with the following meta information set: | ||
// - EXIF Orientation: 6 (Rotated 90° CCW) | ||
// Image data layout (B=black, F=white): | ||
// BFF | ||
// BBB | ||
var testImageURL = | ||
@@ -46,19 +79,110 @@ 'data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAA' + | ||
'QEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE' + | ||
'BAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAEAAgMBEQACEQEDEQH/x' + | ||
'ABKAAEAAAAAAAAAAAAAAAAAAAALEAEAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAAAAAAA' + | ||
'AAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwA/8H//2Q==' | ||
'BAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/x' + | ||
'ABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAA' + | ||
'AAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQ' + | ||
'voP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXw' + | ||
'H/9k=' | ||
var img = document.createElement('img') | ||
img.onload = function () { | ||
// Check if browser supports automatic image orientation: | ||
loadImage.orientation = img.width === 1 && img.height === 2 | ||
// Check if the browser supports automatic image orientation: | ||
$.orientation = img.width === 2 && img.height === 3 | ||
if ($.orientation) { | ||
var canvas = $.createCanvas(1, 1, true) | ||
var ctx = canvas.getContext('2d') | ||
ctx.drawImage(img, 1, 1, 1, 1, 0, 0, 1, 1) | ||
// Check if the source image coordinates (sX, sY, sWidth, sHeight) are | ||
// correctly applied to the auto-orientated image, which should result | ||
// in a white opaque pixel (e.g. in Safari). | ||
// Browsers that show a transparent pixel (e.g. Chromium) fail to crop | ||
// auto-oriented images correctly and require a workaround, e.g. | ||
// drawing the complete source image to an intermediate canvas first. | ||
// See https://bugs.chromium.org/p/chromium/issues/detail?id=1074354 | ||
$.orientationCropBug = | ||
ctx.getImageData(0, 0, 1, 1).data.toString() !== '255,255,255,255' | ||
} | ||
} | ||
img.src = testImageURL | ||
})() | ||
})(loadImage) | ||
/** | ||
* Determines if the orientation requires a canvas element. | ||
* | ||
* @param {object} [options] Options object | ||
* @param {boolean} [withMetaData] Is meta data required for orientation | ||
* @returns {boolean} Returns true if orientation requires canvas/meta | ||
*/ | ||
function requiresCanvasOrientation(options, withMetaData) { | ||
var orientation = options && options.orientation | ||
return ( | ||
// Exif orientation for browsers without automatic image orientation: | ||
(orientation === true && !loadImage.orientation) || | ||
// Orientation reset for browsers with automatic image orientation: | ||
(orientation === 1 && loadImage.orientation) || | ||
// Orientation to defined value, requires meta for orientation reset only: | ||
((!withMetaData || loadImage.orientation) && | ||
orientation > 1 && | ||
orientation < 9) | ||
) | ||
} | ||
/** | ||
* Determines if the image requires an orientation change. | ||
* | ||
* @param {number} [orientation] Defined orientation value | ||
* @param {number} [autoOrientation] Auto-orientation based on Exif data | ||
* @returns {boolean} Returns true if an orientation change is required | ||
*/ | ||
function requiresOrientationChange(orientation, autoOrientation) { | ||
return ( | ||
orientation !== autoOrientation && | ||
((orientation === 1 && autoOrientation > 1 && autoOrientation < 9) || | ||
(orientation > 1 && orientation < 9)) | ||
) | ||
} | ||
/** | ||
* Determines orientation combinations that require a rotation by 180°. | ||
* | ||
* The following is a list of combinations that return true: | ||
* | ||
* 2 (flip) => 5 (rot90,flip), 7 (rot90,flip), 6 (rot90), 8 (rot90) | ||
* 4 (flip) => 5 (rot90,flip), 7 (rot90,flip), 6 (rot90), 8 (rot90) | ||
* | ||
* 5 (rot90,flip) => 2 (flip), 4 (flip), 6 (rot90), 8 (rot90) | ||
* 7 (rot90,flip) => 2 (flip), 4 (flip), 6 (rot90), 8 (rot90) | ||
* | ||
* 6 (rot90) => 2 (flip), 4 (flip), 5 (rot90,flip), 7 (rot90,flip) | ||
* 8 (rot90) => 2 (flip), 4 (flip), 5 (rot90,flip), 7 (rot90,flip) | ||
* | ||
* @param {number} [orientation] Defined orientation value | ||
* @param {number} [autoOrientation] Auto-orientation based on Exif data | ||
* @returns {boolean} Returns true if rotation by 180° is required | ||
*/ | ||
function requiresRot180(orientation, autoOrientation) { | ||
if (autoOrientation > 1 && autoOrientation < 9) { | ||
switch (orientation) { | ||
case 2: | ||
case 4: | ||
return autoOrientation > 4 | ||
case 5: | ||
case 7: | ||
return autoOrientation % 2 === 0 | ||
case 6: | ||
case 8: | ||
return ( | ||
autoOrientation === 2 || | ||
autoOrientation === 4 || | ||
autoOrientation === 5 || | ||
autoOrientation === 7 | ||
) | ||
} | ||
} | ||
return false | ||
} | ||
// Determines if the target image should be a canvas element: | ||
loadImage.hasCanvasOption = function (options) { | ||
loadImage.requiresCanvas = function (options) { | ||
return ( | ||
(!!options.orientation === true && !loadImage.orientation) || | ||
(options.orientation > 1 && options.orientation < 9) || | ||
originalHasCanvasOption.call(loadImage, options) | ||
requiresCanvasOrientation(options) || | ||
originalRequiresCanvas.call(loadImage, options) | ||
) | ||
@@ -68,149 +192,292 @@ } | ||
// Determines if meta data should be loaded automatically: | ||
loadImage.hasMetaOption = function (options) { | ||
loadImage.requiresMetaData = function (options) { | ||
return ( | ||
(options && options.orientation === true && !loadImage.orientation) || | ||
originalHasMetaOption.call(loadImage, options) | ||
requiresCanvasOrientation(options, true) || | ||
originalRequiresMetaData.call(loadImage, options) | ||
) | ||
} | ||
// Transform image orientation based on | ||
// the given EXIF orientation option: | ||
loadImage.transformCoordinates = function (canvas, options) { | ||
originalTransformCoordinates.call(loadImage, canvas, options) | ||
var ctx = canvas.getContext('2d') | ||
var width = canvas.width | ||
var height = canvas.height | ||
var styleWidth = canvas.style.width | ||
var styleHeight = canvas.style.height | ||
loadImage.transform = function (img, options, callback, file, data) { | ||
originalTransform.call( | ||
loadImage, | ||
img, | ||
options, | ||
function (img, data) { | ||
if (data) { | ||
var autoOrientation = | ||
loadImage.orientation && data.exif && data.exif.get('Orientation') | ||
if (autoOrientation > 4 && autoOrientation < 9) { | ||
// Automatic image orientation switched image dimensions | ||
var originalWidth = data.originalWidth | ||
var originalHeight = data.originalHeight | ||
data.originalWidth = originalHeight | ||
data.originalHeight = originalWidth | ||
} | ||
} | ||
callback(img, data) | ||
}, | ||
file, | ||
data | ||
) | ||
} | ||
// Transforms coordinate and dimension options | ||
// based on the given orientation option: | ||
loadImage.getTransformedOptions = function (img, opts, data) { | ||
var options = originalGetTransformedOptions.call(loadImage, img, opts) | ||
var exifOrientation = data.exif && data.exif.get('Orientation') | ||
var orientation = options.orientation | ||
if (!(orientation > 1 && orientation < 9)) { | ||
return | ||
var autoOrientation = loadImage.orientation && exifOrientation | ||
if (orientation === true) orientation = exifOrientation | ||
if (!requiresOrientationChange(orientation, autoOrientation)) { | ||
return options | ||
} | ||
if (orientation > 4) { | ||
canvas.width = height | ||
canvas.height = width | ||
canvas.style.width = styleHeight | ||
canvas.style.height = styleWidth | ||
var top = options.top | ||
var right = options.right | ||
var bottom = options.bottom | ||
var left = options.left | ||
var newOptions = {} | ||
for (var i in options) { | ||
if (Object.prototype.hasOwnProperty.call(options, i)) { | ||
newOptions[i] = options[i] | ||
} | ||
} | ||
newOptions.orientation = orientation | ||
if ( | ||
(orientation > 4 && !(autoOrientation > 4)) || | ||
(orientation < 5 && autoOrientation > 4) | ||
) { | ||
// Image dimensions and target dimensions are switched | ||
newOptions.maxWidth = options.maxHeight | ||
newOptions.maxHeight = options.maxWidth | ||
newOptions.minWidth = options.minHeight | ||
newOptions.minHeight = options.minWidth | ||
newOptions.sourceWidth = options.sourceHeight | ||
newOptions.sourceHeight = options.sourceWidth | ||
} | ||
if (autoOrientation > 1) { | ||
// Browsers which correctly apply source image coordinates to | ||
// auto-oriented images | ||
switch (autoOrientation) { | ||
case 2: | ||
// horizontal flip | ||
right = options.left | ||
left = options.right | ||
break | ||
case 3: | ||
// 180° rotate left | ||
top = options.bottom | ||
right = options.left | ||
bottom = options.top | ||
left = options.right | ||
break | ||
case 4: | ||
// vertical flip | ||
top = options.bottom | ||
bottom = options.top | ||
break | ||
case 5: | ||
// horizontal flip + 90° rotate left | ||
top = options.left | ||
right = options.bottom | ||
bottom = options.right | ||
left = options.top | ||
break | ||
case 6: | ||
// 90° rotate left | ||
top = options.left | ||
right = options.top | ||
bottom = options.right | ||
left = options.bottom | ||
break | ||
case 7: | ||
// vertical flip + 90° rotate left | ||
top = options.right | ||
right = options.top | ||
bottom = options.left | ||
left = options.bottom | ||
break | ||
case 8: | ||
// 90° rotate right | ||
top = options.right | ||
right = options.bottom | ||
bottom = options.left | ||
left = options.top | ||
break | ||
} | ||
// Some orientation combinations require additional rotation by 180°: | ||
if (requiresRot180(orientation, autoOrientation)) { | ||
var tmpTop = top | ||
var tmpRight = right | ||
top = bottom | ||
right = left | ||
bottom = tmpTop | ||
left = tmpRight | ||
} | ||
} | ||
newOptions.top = top | ||
newOptions.right = right | ||
newOptions.bottom = bottom | ||
newOptions.left = left | ||
// Account for defined browser orientation: | ||
switch (orientation) { | ||
case 2: | ||
// horizontal flip | ||
ctx.translate(width, 0) | ||
ctx.scale(-1, 1) | ||
newOptions.right = left | ||
newOptions.left = right | ||
break | ||
case 3: | ||
// 180° rotate left | ||
ctx.translate(width, height) | ||
ctx.rotate(Math.PI) | ||
newOptions.top = bottom | ||
newOptions.right = left | ||
newOptions.bottom = top | ||
newOptions.left = right | ||
break | ||
case 4: | ||
// vertical flip | ||
ctx.translate(0, height) | ||
ctx.scale(1, -1) | ||
newOptions.top = bottom | ||
newOptions.bottom = top | ||
break | ||
case 5: | ||
// vertical flip + 90 rotate right | ||
ctx.rotate(0.5 * Math.PI) | ||
ctx.scale(1, -1) | ||
// vertical flip + 90° rotate right | ||
newOptions.top = left | ||
newOptions.right = bottom | ||
newOptions.bottom = right | ||
newOptions.left = top | ||
break | ||
case 6: | ||
// 90° rotate right | ||
ctx.rotate(0.5 * Math.PI) | ||
ctx.translate(0, -height) | ||
newOptions.top = right | ||
newOptions.right = bottom | ||
newOptions.bottom = left | ||
newOptions.left = top | ||
break | ||
case 7: | ||
// horizontal flip + 90 rotate right | ||
ctx.rotate(0.5 * Math.PI) | ||
ctx.translate(width, -height) | ||
ctx.scale(-1, 1) | ||
// horizontal flip + 90° rotate right | ||
newOptions.top = right | ||
newOptions.right = top | ||
newOptions.bottom = left | ||
newOptions.left = bottom | ||
break | ||
case 8: | ||
// 90° rotate left | ||
ctx.rotate(-0.5 * Math.PI) | ||
ctx.translate(-width, 0) | ||
newOptions.top = left | ||
newOptions.right = top | ||
newOptions.bottom = right | ||
newOptions.left = bottom | ||
break | ||
} | ||
return newOptions | ||
} | ||
// Transforms coordinate and dimension options | ||
// based on the given orientation option: | ||
loadImage.getTransformedOptions = function (img, opts, data) { | ||
var options = originalGetTransformedOptions.call(loadImage, img, opts) | ||
// Transform image orientation based on the given EXIF orientation option: | ||
loadImage.transformCoordinates = function (canvas, options, data) { | ||
originalTransformCoordinates.call(loadImage, canvas, options, data) | ||
var orientation = options.orientation | ||
var newOptions | ||
var i | ||
if (orientation === true) { | ||
if (loadImage.orientation) { | ||
// Browser supports automatic image orientation | ||
return options | ||
} | ||
orientation = data && data.exif && data.exif.get('Orientation') | ||
var autoOrientation = | ||
loadImage.orientation && data.exif && data.exif.get('Orientation') | ||
if (!requiresOrientationChange(orientation, autoOrientation)) { | ||
return | ||
} | ||
if (!(orientation > 1 && orientation < 9)) { | ||
return options | ||
var ctx = canvas.getContext('2d') | ||
var width = canvas.width | ||
var height = canvas.height | ||
var sourceWidth = width | ||
var sourceHeight = height | ||
if ( | ||
(orientation > 4 && !(autoOrientation > 4)) || | ||
(orientation < 5 && autoOrientation > 4) | ||
) { | ||
// Image dimensions and target dimensions are switched | ||
canvas.width = height | ||
canvas.height = width | ||
} | ||
newOptions = {} | ||
for (i in options) { | ||
if (Object.prototype.hasOwnProperty.call(options, i)) { | ||
newOptions[i] = options[i] | ||
} | ||
if (orientation > 4) { | ||
// Destination and source dimensions are switched | ||
sourceWidth = height | ||
sourceHeight = width | ||
} | ||
newOptions.orientation = orientation | ||
// Reset automatic browser orientation: | ||
switch (autoOrientation) { | ||
case 2: | ||
// horizontal flip | ||
ctx.translate(sourceWidth, 0) | ||
ctx.scale(-1, 1) | ||
break | ||
case 3: | ||
// 180° rotate left | ||
ctx.translate(sourceWidth, sourceHeight) | ||
ctx.rotate(Math.PI) | ||
break | ||
case 4: | ||
// vertical flip | ||
ctx.translate(0, sourceHeight) | ||
ctx.scale(1, -1) | ||
break | ||
case 5: | ||
// horizontal flip + 90° rotate left | ||
ctx.rotate(-0.5 * Math.PI) | ||
ctx.scale(-1, 1) | ||
break | ||
case 6: | ||
// 90° rotate left | ||
ctx.rotate(-0.5 * Math.PI) | ||
ctx.translate(-sourceWidth, 0) | ||
break | ||
case 7: | ||
// vertical flip + 90° rotate left | ||
ctx.rotate(-0.5 * Math.PI) | ||
ctx.translate(-sourceWidth, sourceHeight) | ||
ctx.scale(1, -1) | ||
break | ||
case 8: | ||
// 90° rotate right | ||
ctx.rotate(0.5 * Math.PI) | ||
ctx.translate(0, -sourceHeight) | ||
break | ||
} | ||
// Some orientation combinations require additional rotation by 180°: | ||
if (requiresRot180(orientation, autoOrientation)) { | ||
ctx.translate(sourceWidth, sourceHeight) | ||
ctx.rotate(Math.PI) | ||
} | ||
switch (orientation) { | ||
case 2: | ||
// horizontal flip | ||
newOptions.left = options.right | ||
newOptions.right = options.left | ||
ctx.translate(width, 0) | ||
ctx.scale(-1, 1) | ||
break | ||
case 3: | ||
// 180° rotate left | ||
newOptions.left = options.right | ||
newOptions.top = options.bottom | ||
newOptions.right = options.left | ||
newOptions.bottom = options.top | ||
ctx.translate(width, height) | ||
ctx.rotate(Math.PI) | ||
break | ||
case 4: | ||
// vertical flip | ||
newOptions.top = options.bottom | ||
newOptions.bottom = options.top | ||
ctx.translate(0, height) | ||
ctx.scale(1, -1) | ||
break | ||
case 5: | ||
// vertical flip + 90 rotate right | ||
newOptions.left = options.top | ||
newOptions.top = options.left | ||
newOptions.right = options.bottom | ||
newOptions.bottom = options.right | ||
// vertical flip + 90° rotate right | ||
ctx.rotate(0.5 * Math.PI) | ||
ctx.scale(1, -1) | ||
break | ||
case 6: | ||
// 90° rotate right | ||
newOptions.left = options.top | ||
newOptions.top = options.right | ||
newOptions.right = options.bottom | ||
newOptions.bottom = options.left | ||
ctx.rotate(0.5 * Math.PI) | ||
ctx.translate(0, -height) | ||
break | ||
case 7: | ||
// horizontal flip + 90 rotate right | ||
newOptions.left = options.bottom | ||
newOptions.top = options.right | ||
newOptions.right = options.top | ||
newOptions.bottom = options.left | ||
// horizontal flip + 90° rotate right | ||
ctx.rotate(0.5 * Math.PI) | ||
ctx.translate(width, -height) | ||
ctx.scale(-1, 1) | ||
break | ||
case 8: | ||
// 90° rotate left | ||
newOptions.left = options.bottom | ||
newOptions.top = options.left | ||
newOptions.right = options.top | ||
newOptions.bottom = options.right | ||
ctx.rotate(-0.5 * Math.PI) | ||
ctx.translate(-width, 0) | ||
break | ||
} | ||
if (newOptions.orientation > 4) { | ||
newOptions.maxWidth = options.maxHeight | ||
newOptions.maxHeight = options.maxWidth | ||
newOptions.minWidth = options.minHeight | ||
newOptions.minHeight = options.minWidth | ||
newOptions.sourceWidth = options.sourceHeight | ||
newOptions.sourceHeight = options.sourceWidth | ||
} | ||
return newOptions | ||
} | ||
}) |
@@ -30,2 +30,12 @@ /* | ||
loadImage.createCanvas = function (width, height, offscreen) { | ||
if (offscreen && loadImage.global.OffscreenCanvas) { | ||
return new OffscreenCanvas(width, height) | ||
} | ||
var canvas = document.createElement('canvas') | ||
canvas.width = width | ||
canvas.height = height | ||
return canvas | ||
} | ||
loadImage.transform = function (img, options, callback, file, data) { | ||
@@ -44,3 +54,3 @@ originalTransform.call( | ||
// the canvas orientation based on the orientation option, | ||
// gets canvas, options passed as arguments: | ||
// gets canvas, options and data passed as arguments: | ||
loadImage.transformCoordinates = function () {} | ||
@@ -50,3 +60,3 @@ | ||
// maxWidth, maxHeight and crop options based on the aspectRatio. | ||
// gets img, options passed as arguments: | ||
// gets img, options, data passed as arguments: | ||
loadImage.getTransformedOptions = function (img, options) { | ||
@@ -81,5 +91,5 @@ var aspectRatio = options.aspectRatio | ||
// Canvas render method, allows to implement a different rendering algorithm: | ||
loadImage.renderImageToCanvas = function ( | ||
loadImage.drawImage = function ( | ||
img, | ||
canvas, | ||
img, | ||
sourceX, | ||
@@ -89,4 +99,2 @@ sourceY, | ||
sourceHeight, | ||
destX, | ||
destY, | ||
destWidth, | ||
@@ -98,2 +106,3 @@ destHeight, | ||
if (options.imageSmoothingEnabled === false) { | ||
ctx.msImageSmoothingEnabled = false | ||
ctx.imageSmoothingEnabled = false | ||
@@ -109,12 +118,12 @@ } else if (options.imageSmoothingQuality) { | ||
sourceHeight, | ||
destX, | ||
destY, | ||
0, | ||
0, | ||
destWidth, | ||
destHeight | ||
) | ||
return canvas | ||
return ctx | ||
} | ||
// Determines if the target image should be a canvas element: | ||
loadImage.hasCanvasOption = function (options) { | ||
loadImage.requiresCanvas = function (options) { | ||
return options.canvas || options.crop || !!options.aspectRatio | ||
@@ -124,13 +133,12 @@ } | ||
// Scales and/or crops the given image (img or canvas HTML element) | ||
// using the given options. | ||
// Returns a canvas object if the browser supports canvas | ||
// and the hasCanvasOption method returns true or a canvas | ||
// object is passed as image, else the scaled image: | ||
// using the given options: | ||
loadImage.scale = function (img, options, data) { | ||
// eslint-disable-next-line no-param-reassign | ||
options = options || {} | ||
var canvas = document.createElement('canvas') | ||
// eslint-disable-next-line no-param-reassign | ||
data = data || {} | ||
var useCanvas = | ||
img.getContext || | ||
(loadImage.hasCanvasOption(options) && canvas.getContext) | ||
(loadImage.requiresCanvas(options) && | ||
!!loadImage.global.HTMLCanvasElement) | ||
var width = img.naturalWidth || img.width | ||
@@ -151,2 +159,3 @@ var height = img.naturalHeight || img.height | ||
var tmp | ||
var canvas | ||
/** | ||
@@ -236,9 +245,33 @@ * Scales up image dimensions | ||
pixelRatio = options.pixelRatio | ||
if (pixelRatio > 1) { | ||
canvas.style.width = destWidth + 'px' | ||
canvas.style.height = destHeight + 'px' | ||
if ( | ||
pixelRatio > 1 && | ||
// Check if image has not yet device pixel ratio applied: | ||
parseInt(img.style.width, 10) !== width / pixelRatio | ||
) { | ||
destWidth *= pixelRatio | ||
destHeight *= pixelRatio | ||
canvas.getContext('2d').scale(pixelRatio, pixelRatio) | ||
} | ||
// Check if workaround for Chromium orientation crop bug is required: | ||
// https://bugs.chromium.org/p/chromium/issues/detail?id=1074354 | ||
if ( | ||
loadImage.orientationCropBug && | ||
!img.getContext && | ||
(sourceX || sourceY || sourceWidth !== width || sourceHeight !== height) | ||
) { | ||
// Write the complete source image to an intermediate canvas first: | ||
tmp = img | ||
// eslint-disable-next-line no-param-reassign | ||
img = loadImage.createCanvas(width, height, true) | ||
loadImage.drawImage( | ||
tmp, | ||
img, | ||
0, | ||
0, | ||
width, | ||
height, | ||
width, | ||
height, | ||
options | ||
) | ||
} | ||
downsamplingRatio = options.downsamplingRatio | ||
@@ -252,7 +285,10 @@ if ( | ||
while (sourceWidth * downsamplingRatio > destWidth) { | ||
canvas.width = sourceWidth * downsamplingRatio | ||
canvas.height = sourceHeight * downsamplingRatio | ||
loadImage.renderImageToCanvas( | ||
canvas = loadImage.createCanvas( | ||
sourceWidth * downsamplingRatio, | ||
sourceHeight * downsamplingRatio, | ||
true | ||
) | ||
loadImage.drawImage( | ||
img, | ||
canvas, | ||
img, | ||
sourceX, | ||
@@ -262,4 +298,2 @@ sourceY, | ||
sourceHeight, | ||
0, | ||
0, | ||
canvas.width, | ||
@@ -274,36 +308,25 @@ canvas.height, | ||
// eslint-disable-next-line no-param-reassign | ||
img = document.createElement('canvas') | ||
img.width = sourceWidth | ||
img.height = sourceHeight | ||
loadImage.renderImageToCanvas( | ||
img, | ||
canvas, | ||
0, | ||
0, | ||
sourceWidth, | ||
sourceHeight, | ||
0, | ||
0, | ||
sourceWidth, | ||
sourceHeight, | ||
options | ||
) | ||
img = canvas | ||
} | ||
} | ||
canvas.width = destWidth | ||
canvas.height = destHeight | ||
loadImage.transformCoordinates(canvas, options) | ||
return loadImage.renderImageToCanvas( | ||
canvas, | ||
img, | ||
sourceX, | ||
sourceY, | ||
sourceWidth, | ||
sourceHeight, | ||
0, | ||
0, | ||
destWidth, | ||
destHeight, | ||
options | ||
) | ||
canvas = loadImage.createCanvas(destWidth, destHeight) | ||
loadImage.transformCoordinates(canvas, options, data) | ||
if (pixelRatio > 1) { | ||
canvas.style.width = canvas.width / pixelRatio + 'px' | ||
canvas.style.height = canvas.height / pixelRatio + 'px' | ||
} | ||
loadImage | ||
.drawImage( | ||
img, | ||
canvas, | ||
sourceX, | ||
sourceY, | ||
sourceWidth, | ||
sourceHeight, | ||
destWidth, | ||
destHeight, | ||
options | ||
) | ||
.setTransform(1, 0, 0, 1, 0, 0) // reset to the identity matrix | ||
return canvas | ||
} | ||
@@ -310,0 +333,0 @@ img.width = destWidth |
@@ -1,2 +0,2 @@ | ||
!function(a){"use strict";function s(i,n,a){var o,r=document.createElement("img");function e(e,t){t&&console.log(t),e&&s.isInstanceOf("Blob",e)?o=s.createObjectURL(i=e):(o=i,a&&a.crossOrigin&&(r.crossOrigin=a.crossOrigin)),r.src=o}return r.onerror=function(e){return s.onerror(r,e,i,o,n,a)},r.onload=function(e){return s.onload(r,e,i,o,n,a)},"string"==typeof i?(s.hasMetaOption(a)?s.fetchBlob(i,e,a):e(),r):s.isInstanceOf("Blob",i)||s.isInstanceOf("File",i)?(o=s.createObjectURL(i))?(r.src=o,r):s.readFile(i,function(e){var t=e.target;t&&t.result?r.src=t.result:n&&n(e)}):void 0}var t=a.createObjectURL&&a||a.URL&&URL.revokeObjectURL&&URL||a.webkitURL&&webkitURL;function r(e,t){!e||"blob:"!==e.slice(0,5)||t&&t.noRevoke||s.revokeObjectURL(e)}s.hasMetaOption=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,n,a){i(e,a)},s.onerror=function(e,t,i,n,a,o){r(n,o),a&&a.call(e,t)},s.onload=function(e,t,i,n,a,o){r(n,o),a&&s.transform(e,o,a,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(a.FileReader){var n=new FileReader;if(n.onload=n.onerror=t,n[i=i||"readAsDataURL"])return n[i](e),n}return!1},"function"==typeof define&&define.amd?define(function(){return s}):"object"==typeof module&&module.exports?module.exports=s:a.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 o=x.transform;x.transform=function(e,t,i,n,a){o.call(x,x.scale(e,t,a),t,i,n,a)},x.transformCoordinates=function(){},x.getTransformedOptions=function(e,t){var i,n,a,o,r=t.aspectRatio;if(!r)return t;for(n in i={},t)Object.prototype.hasOwnProperty.call(t,n)&&(i[n]=t[n]);return i.crop=!0,r<(a=e.naturalWidth||e.width)/(o=e.naturalHeight||e.height)?(i.maxWidth=o*r,i.maxHeight=o):(i.maxWidth=a,i.maxHeight=a/r),i},x.renderImageToCanvas=function(e,t,i,n,a,o,r,s,l,c,d){var u=e.getContext("2d");return!1===d.imageSmoothingEnabled?u.imageSmoothingEnabled=!1:d.imageSmoothingQuality&&(u.imageSmoothingQuality=d.imageSmoothingQuality),u.drawImage(t,i,n,a,o,r,s,l,c),e},x.hasCanvasOption=function(e){return e.canvas||e.crop||!!e.aspectRatio},x.scale=function(e,t,i){t=t||{};var n,a,o,r,s,l,c,d,u,f,g,m=document.createElement("canvas"),h=e.getContext||x.hasCanvasOption(t)&&m.getContext,p=e.naturalWidth||e.width,A=e.naturalHeight||e.height,b=p,y=A;function S(){var e=Math.max((o||b)/b,(r||y)/y);1<e&&(b*=e,y*=e)}function v(){var e=Math.min((n||b)/b,(a||y)/y);e<1&&(b*=e,y*=e)}if(h&&(c=(t=x.getTransformedOptions(e,t,i)).left||0,d=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&&(d=A-l-t.bottom)):l=A-d-(t.bottom||0),b=s,y=l),n=t.maxWidth,a=t.maxHeight,o=t.minWidth,r=t.minHeight,h&&n&&a&&t.crop?(g=s/l-(b=n)/(y=a))<0?(l=a*s/n,void 0===t.top&&void 0===t.bottom&&(d=(A-l)/2)):0<g&&(s=n*l/a,void 0===t.left&&void 0===t.right&&(c=(p-s)/2)):((t.contain||t.cover)&&(o=n=n||o,r=a=a||r),t.cover?(v(),S()):(S(),v())),h){if(1<(u=t.pixelRatio)&&(m.style.width=b+"px",m.style.height=y+"px",b*=u,y*=u,m.getContext("2d").scale(u,u)),0<(f=t.downsamplingRatio)&&f<1&&b<s&&y<l)for(;b<s*f;)m.width=s*f,m.height=l*f,x.renderImageToCanvas(m,e,c,d,s,l,0,0,m.width,m.height,t),d=c=0,s=m.width,l=m.height,(e=document.createElement("canvas")).width=s,e.height=l,x.renderImageToCanvas(e,m,0,0,s,l,0,0,s,l,t);return m.width=b,m.height=y,x.transformCoordinates(m,t),x.renderImageToCanvas(m,e,c,d,s,l,0,0,b,y,t)}return e.width=b,e.height=y,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";var e="undefined"!=typeof Blob&&(Blob.prototype.slice||Blob.prototype.webkitSlice||Blob.prototype.mozSlice);m.blobSlice=e&&function(){return(this.slice||this.webkitSlice||this.mozSlice).apply(this,arguments)},m.metaDataParsers={jpeg:{65505:[],65517:[]}},m.parseMetaData=function(e,d,u,f){f=f||{};var g=this,t=(u=u||{}).maxMetaDataSize||262144;!!("undefined"!=typeof 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 d(f);var t,i,n,a,o=e.target.result,r=new DataView(o),s=2,l=r.byteLength-4,c=s;if(65496===r.getUint16(0)){for(;s<l&&(65504<=(t=r.getUint16(s))&&t<=65519||65534===t);){if(s+(i=r.getUint16(s+2)+2)>r.byteLength){console.log("Invalid meta data: Invalid segment size.");break}if((n=m.metaDataParsers.jpeg[t])&&!u.disableMetaDataParsers)for(a=0;a<n.length;a+=1)n[a].call(g,r,s,i,f,u);c=s+=i}!u.disableImageHead&&6<c&&(o.slice?f.imageHead=o.slice(0,c):f.imageHead=new Uint8Array(o).subarray(0,c))}else console.log("Invalid JPEG file: Missing JPEG marker.");d(f)},"readAsArrayBuffer")||d(f)},m.replaceHead=function(t,i,n){m.parseMetaData(t,function(e){n(new Blob([i,m.blobSlice.call(t,e.imageHead.byteLength)],{type:"image/jpeg"}))},{maxMetaDataSize:256,disableMetaDataParsers:!0})};var o=m.transform;m.transform=function(t,i,n,a,e){m.hasMetaOption(i)?m.parseMetaData(a,function(e){o.call(m,t,i,n,a,e)},i,e):o.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 n=new XMLHttpRequest;n.open(i.method||"GET",e),i.headers&&Object.keys(i.headers).forEach(function(e){n.setRequestHeader(e,i.headers[e])}),n.withCredentials="include"===i.credentials,n.responseType="blob",n.onload=function(){t(n.response)},n.onerror=n.onabort=n.ontimeout=function(e){t(null,e)},n.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(l){"use strict";var e,t=l.hasCanvasOption,i=l.hasMetaOption,c=l.transformCoordinates,s=l.getTransformedOptions;(e=document.createElement("img")).onload=function(){l.orientation=1===e.width&&2===e.height},e.src="data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAEAAgMBEQACEQEDEQH/xABKAAEAAAAAAAAAAAAAAAAAAAALEAEAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAAAAAAAAAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwA/8H//2Q==",l.hasCanvasOption=function(e){return!0==!!e.orientation&&!l.orientation||1<e.orientation&&e.orientation<9||t.call(l,e)},l.hasMetaOption=function(e){return e&&!0===e.orientation&&!l.orientation||i.call(l,e)},l.transformCoordinates=function(e,t){c.call(l,e,t);var i=e.getContext("2d"),n=e.width,a=e.height,o=e.style.width,r=e.style.height,s=t.orientation;if(1<s&&s<9)switch(4<s&&(e.width=a,e.height=n,e.style.width=r,e.style.height=o),s){case 2:i.translate(n,0),i.scale(-1,1);break;case 3:i.translate(n,a),i.rotate(Math.PI);break;case 4:i.translate(0,a),i.scale(1,-1);break;case 5:i.rotate(.5*Math.PI),i.scale(1,-1);break;case 6:i.rotate(.5*Math.PI),i.translate(0,-a);break;case 7:i.rotate(.5*Math.PI),i.translate(n,-a),i.scale(-1,1);break;case 8:i.rotate(-.5*Math.PI),i.translate(-n,0)}},l.getTransformedOptions=function(e,t,i){var n,a,o=s.call(l,e,t),r=o.orientation;if(!0===r){if(l.orientation)return o;r=i&&i.exif&&i.exif.get("Orientation")}if(!(1<r&&r<9))return o;for(a in n={},o)Object.prototype.hasOwnProperty.call(o,a)&&(n[a]=o[a]);switch(n.orientation=r){case 2:n.left=o.right,n.right=o.left;break;case 3:n.left=o.right,n.top=o.bottom,n.right=o.left,n.bottom=o.top;break;case 4:n.top=o.bottom,n.bottom=o.top;break;case 5:n.left=o.top,n.top=o.left,n.right=o.bottom,n.bottom=o.right;break;case 6:n.left=o.top,n.top=o.right,n.right=o.bottom,n.bottom=o.left;break;case 7:n.left=o.bottom,n.top=o.right,n.right=o.top,n.bottom=o.left;break;case 8:n.left=o.bottom,n.top=o.left,n.right=o.top,n.bottom=o.right}return 4<n.orientation&&(n.maxWidth=o.maxHeight,n.maxHeight=o.maxWidth,n.minWidth=o.minHeight,n.minHeight=o.minWidth,n.sourceWidth=o.sourceHeight,n.sourceHeight=o.sourceWidth),n}}),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(a){"use strict";function h(e){e&&(Object.defineProperty(this,"map",{value:this.privateIFDs[e].map}),Object.defineProperty(this,"tags",{value:this.tags&&this.tags[e]||{}}))}h.prototype.map={Orientation:274,Thumbnail:513,Exif:34665,GPSInfo:34853,Interoperability:40965},h.prototype.privateIFDs={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,n,a,o){var r,s,l,c,d,u,f=g[n];if(f){if(!((s=4<(r=f.size*a)?t+e.getUint32(i+8,o):i+8)+r>e.byteLength)){if(1===a)return f.getValue(e,s,o);for(l=[],c=0;c<a;c+=1)l[c]=f.getValue(e,s+c*f.size,o);if(f.ascii){for(d="",c=0;c<l.length&&"\0"!==(u=l[c]);c+=1)d+=u;return d}return l}console.log("Invalid Exif data: Invalid data offset.")}else console.log("Invalid Exif data: Invalid tag type.")}function p(e,t,i,n,a,o,r,s){var l,c,d,u,f,g;if(i+6>e.byteLength)console.log("Invalid Exif data: Invalid directory offset.");else{if(!((c=i+2+12*(l=e.getUint16(i,n)))+4>e.byteLength)){for(d=0;d<l;d+=1)u=i+2+12*d,f=e.getUint16(u,n),r&&!r[f]||s&&!0===s[f]||(g=m(e,t,u,e.getUint16(u+2,n),e.getUint32(u+4,n),n),a[f]=g,o&&(o[f]=u));return e.getUint32(c,n)}console.log("Invalid Exif data: Invalid directory size.")}}g[7]=g[1],a.parseExifData=function(c,e,t,d,i){if(!i.disableExif){var u,n,f=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)?(n=c.getUint32(m+4,u),d.exif=new h,i.disableExifOffsets||(d.exifOffsets=new h,d.exifTiffOffset=m,d.exifLittleEndian=u),(n=p(c,m,m+n,u,d.exif,d.exifOffsets,f,g))&&!i.disableExifThumbnail&&(n=p(c,m,m+n,u,d.exif,d.exifOffsets,f,g),d.exif[513]&&d.exif[514]&&(d.exif[513]=function(e,t,i){if(i&&!(t+i>e.byteLength))return new Blob([e.buffer.slice(t,t+i)],{type:"image/jpeg"});console.log("Invalid Exif data: Invalid thumbnail data.")}(c,m+d.exif[513],d.exif[514]))),Object.keys(d.exif.privateIFDs).forEach(function(e){var t,i,n,a,o,r,s,l;i=e,n=c,a=m,o=u,r=f,s=g,(l=(t=d).exif[i])&&(t.exif[i]=new h(i),t.exifOffsets&&(t.exifOffsets[i]=new h(i)),p(n,a,a+l,o,t.exif[i],t.exifOffsets&&t.exifOffsets[i],r&&r[i],s&&s[i]))})):console.log("Invalid Exif data: Missing TIFF marker.")}else console.log("Invalid Exif data: Missing byte alignment offset.")}},a.metaDataParsers.jpeg[65505].push(a.parseExifData),a.exifWriters={274:function(e,t,i){return new DataView(e,t.exifOffsets[274]+8,2).setUint16(0,i,t.exifLittleEndian),e}},a.writeExifData=function(e,t,i,n){a.exifWriters[t.exif.map[i]](e,t,n)},a.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 a=e.ExifMap.prototype;a.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",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"}},a.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"}},a.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)},a.getAll=function(){var e,t,i,n={};for(e in this)Object.prototype.hasOwnProperty.call(this,e)&&((t=this[e])&&t.getAll?n[this.privateIFDs[e].name]=t.getAll():(i=this.tags[e])&&(n[i]=this.getText(i)));return n},a.getName=function(e){var t=this.tags[e];return"object"==typeof t?this.privateIFDs[e].name:t},function(){var e,t,i,n=a.tags;for(e in n)if(Object.prototype.hasOwnProperty.call(n,e))if(t=a.privateIFDs[e])for(e in i=n[e])Object.prototype.hasOwnProperty.call(i,e)&&(t.map[i[e]]=Number(e));else a.map[n[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,n,a){return"binary"===t.types[e]?new Blob([i.buffer.slice(n,n+a)]):"Uint16"===t.types[e]?i.getUint16(n):function(e,t,i){for(var n="",a=t+i,o=t;o<a;o+=1)n+=String.fromCharCode(e.getUint8(o));return n}(i,n,a)}function h(e,t,i,n,a,o){for(var r,s,l,c,d,u=t+i,f=t;f<u;)28===e.getUint8(f)&&2===e.getUint8(f+1)&&(l=e.getUint8(f+2),a&&!a[l]||o&&o[l]||(s=e.getInt16(f+3),r=m(l,n.iptc,e,f+5,s),n.iptc[l]=(c=n.iptc[l],d=r,void 0===c?d:c instanceof Array?(c.push(d),c):[c,d]),n.iptcOffsets&&(n.iptcOffsets[l]=f))),f+=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,n,a){if(!a.disableIptc)for(var o,r,s,l,c=t+i;t+8<c;){if(l=t,943868237===(s=e).getUint32(l)&&1028===s.getUint16(l+4)){var d=(o=t,r=void 0,(r=e.getUint8(o+7))%2!=0&&(r+=1),0===r&&(r=4),r),u=t+8+d;if(c<u){console.log("Invalid IPTC data: Invalid segment offset.");break}var f=e.getUint16(t+6+d);if(c<t+f){console.log("Invalid IPTC data: Invalid segment size.");break}return n.iptc=new g,a.disableIptcOffsets||(n.iptcOffsets=new g),void h(e,u,f,n,a.includeIptcTags,a.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 n=e.IptcMap.prototype;n.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"},n.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"}},n.getText=function(e){var t=this.get(e),i=this.map[e],n=this.stringValues[i];return n?n[t]:String(t)},n.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},n.getName=function(e){return this.tags[e]},function(){var e,t=n.tags,i=n.map||{};for(e in t)Object.prototype.hasOwnProperty.call(t,e)&&(i[t[e]]=Number(e))}()}); | ||
!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,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},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,c,l,u,f,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&&(l=(t=x.getTransformedOptions(e,t,i)).left||0,u=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&&(u=A-c-t.bottom)):c=A-u-(t.bottom||0),b=s,S=c),a=t.maxWidth,n=t.maxHeight,r=t.minWidth,o=t.minHeight,h&&a&&n&&t.crop?(g=s/c-(b=a)/(S=n))<0?(c=n*s/a,void 0===t.top&&void 0===t.bottom&&(u=(A-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<(f=t.pixelRatio)&&parseInt(e.style.width,10)!==p/f&&(b*=f,S*=f),x.orientationCropBug&&!e.getContext&&(l||u||s!==p||c!==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<c)for(;b<s*d;)m=x.createCanvas(s*d,c*d,!0),x.drawImage(e,m,l,u,s,c,m.width,m.height,t),u=l=0,s=m.width,c=m.height,e=m;return m=x.createCanvas(b,S),x.transformCoordinates(m,t,i),1<f&&(m.style.width=m.width/f+"px",m.style.height=m.height/f+"px"),x.drawImage(e,m,l,u,s,c,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(p){"use strict";var e="undefined"!=typeof Blob&&(Blob.prototype.slice||Blob.prototype.webkitSlice||Blob.prototype.mozSlice);p.blobSlice=e&&function(){return(this.slice||this.webkitSlice||this.mozSlice).apply(this,arguments)},p.metaDataParsers={jpeg:{65505:[],65517:[]}},p.parseMetaData=function(e,d,g,m){m=m||{};var h=this,t=(g=g||{}).maxMetaDataSize||262144;!!("undefined"!=typeof DataView&&e&&12<=e.size&&"image/jpeg"===e.type&&p.blobSlice)&&p.readFile(p.blobSlice.call(e,0,t),function(e){if(e.target.error)return console.log(e.target.error),void d(m);var t,i,a,n,r,o,s=e.target.result,c=new DataView(s),l=2,u=c.byteLength-4,f=l;if(65496===c.getUint16(0)){for(;l<u&&(65504<=(t=c.getUint16(l))&&t<=65519||65534===t);){if(l+(i=c.getUint16(l+2)+2)>c.byteLength){console.log("Invalid meta data: Invalid segment size.");break}if((a=p.metaDataParsers.jpeg[t])&&!g.disableMetaDataParsers)for(n=0;n<a.length;n+=1)a[n].call(h,c,l,i,m,g);f=l+=i}!g.disableImageHead&&6<f&&(s.slice?m.imageHead=s.slice(0,f):(r=new Uint8Array(s,0,f),(o=new Uint8Array(f)).set(r),m.imageHead=o.buffer))}else console.log("Invalid JPEG file: Missing JPEG marker.");d(m)},"readAsArrayBuffer")||d(m)},p.replaceHead=function(t,i,a){p.parseMetaData(t,function(e){a(new Blob([i,p.blobSlice.call(t,e.imageHead.byteLength)],{type:"image/jpeg"}))},{maxMetaDataSize:256,disableMetaDataParsers:!0})};var r=p.transform;p.transform=function(t,i,a,n,e){p.requiresMetaData(i)?p.parseMetaData(n,function(e){r.call(p,t,i,a,n,e)},i,e):r.apply(p,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 t,i,n=h.transform,a=h.requiresCanvas,r=h.requiresMetaData,u=h.transformCoordinates,p=h.getTransformedOptions;function o(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}}t=h,(i=document.createElement("img")).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.requiresCanvas=function(e){return o(e)||a.call(h,e)},h.requiresMetaData=function(e){return o(e,!0)||r.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,c=a.right,l=a.bottom,u=a.left,f={};for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&(f[d]=a[d]);if((4<(f.orientation=r)&&!(4<o)||r<5&&4<o)&&(f.maxWidth=a.maxHeight,f.maxHeight=a.maxWidth,f.minWidth=a.minHeight,f.minHeight=a.minWidth,f.sourceWidth=a.sourceHeight,f.sourceHeight=a.sourceWidth),1<o){switch(o){case 2:c=a.left,u=a.right;break;case 3:s=a.bottom,c=a.left,l=a.top,u=a.right;break;case 4:s=a.bottom,l=a.top;break;case 5:s=a.left,c=a.bottom,l=a.right,u=a.top;break;case 6:s=a.left,c=a.top,l=a.right,u=a.bottom;break;case 7:s=a.right,c=a.top,l=a.left,u=a.bottom;break;case 8:s=a.right,c=a.bottom,l=a.left,u=a.top}if(b(r,o)){var g=s,m=c;s=l,c=u,l=g,u=m}}switch(f.top=s,f.right=c,f.bottom=l,f.left=u,r){case 2:f.right=u,f.left=c;break;case 3:f.top=l,f.right=u,f.bottom=s,f.left=c;break;case 4:f.top=l,f.bottom=s;break;case 5:f.top=u,f.right=l,f.bottom=c,f.left=s;break;case 6:f.top=c,f.right=l,f.bottom=u,f.left=s;break;case 7:f.top=c,f.right=s,f.bottom=u,f.left=l;break;case 8:f.top=u,f.right=s,f.bottom=c,f.left=l}return f},h.transformCoordinates=function(e,t,i){u.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,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(b(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(n){"use strict";function h(e){e&&(Object.defineProperty(this,"map",{value:this.privateIFDs[e].map}),Object.defineProperty(this,"tags",{value:this.tags&&this.tags[e]||{}}))}h.prototype.map={Orientation:274,Thumbnail:513,Exif:34665,GPSInfo:34853,Interoperability:40965},h.prototype.privateIFDs={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,u,f,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(u="",l=0;l<c.length&&"\0"!==(f=c[l]);l+=1)u+=f;return u}return c}console.log("Invalid Exif data: Invalid data offset.")}else console.log("Invalid Exif data: Invalid tag type.")}function p(e,t,i,a,n,r,o,s){var c,l,u,f,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(u=0;u<c;u+=1)f=i+2+12*u,d=e.getUint16(f,a),o&&!o[d]||s&&!0===s[d]||(g=m(e,t,f,e.getUint16(f+2,a),e.getUint32(f+4,a),a),n[d]=g,r&&(r[d]=f));return e.getUint32(l,a)}console.log("Invalid Exif data: Invalid directory size.")}}g[7]=g[1],n.parseExifData=function(l,e,t,u,i){if(!i.disableExif){var f,a,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:f=!0;break;case 19789:f=!1;break;default:return void console.log("Invalid Exif data: Invalid byte alignment marker.")}42===l.getUint16(m+2,f)?(a=l.getUint32(m+4,f),u.exif=new h,i.disableExifOffsets||(u.exifOffsets=new h,u.exifTiffOffset=m,u.exifLittleEndian=f),(a=p(l,m,m+a,f,u.exif,u.exifOffsets,d,g))&&!i.disableExifThumbnail&&(a=p(l,m,m+a,f,u.exif,u.exifOffsets,d,g),u.exif[513]&&u.exif[514]&&(u.exif[513]=function(e,t,i){if(i&&!(t+i>e.byteLength))return new Blob([e.buffer.slice(t,t+i)],{type:"image/jpeg"});console.log("Invalid Exif data: Invalid thumbnail data.")}(l,m+u.exif[513],u.exif[514]))),Object.keys(u.exif.privateIFDs).forEach(function(e){var t,i,a,n,r,o,s,c;i=e,a=l,n=m,r=f,o=d,s=g,(c=(t=u).exif[i])&&(t.exif[i]=new h(i),t.exifOffsets&&(t.exifOffsets[i]=new h(i)),p(a,n,n+c,r,t.exif[i],t.exifOffsets&&t.exifOffsets[i],o&&o[i],s&&s[i]))})):console.log("Invalid Exif data: Missing TIFF marker.")}else console.log("Invalid Exif data: Missing byte alignment offset.")}},n.metaDataParsers.jpeg[65505].push(n.parseExifData),n.exifWriters={274:function(e,t,i){return new DataView(e,t.exifOffsets[274]+8,2).setUint16(0,i,t.exifLittleEndian),e}},n.writeExifData=function(e,t,i,a){n.exifWriters[t.exif.map[i]](e,t,a)},n.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",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.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.privateIFDs[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.privateIFDs[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.privateIFDs[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,u,f=t+i,d=t;d<f;)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],u=o,void 0===l?u:l instanceof Array?(l.push(u),l):[l,u]),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 u=(r=t,o=void 0,(o=e.getUint8(r+7))%2!=0&&(o+=1),0===o&&(o=4),o),f=t+8+u;if(l<f){console.log("Invalid IPTC data: Invalid segment offset.");break}var d=e.getUint16(t+6+u);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,f,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 |
@@ -57,3 +57,3 @@ /* | ||
if (typeof file === 'string') { | ||
if (loadImage.hasMetaOption(options)) { | ||
if (loadImage.requiresMetaData(options)) { | ||
loadImage.fetchBlob(file, fetchBlobCallback, options) | ||
@@ -106,3 +106,3 @@ } else { | ||
// Requires the load image meta extension to load meta data. | ||
loadImage.hasMetaOption = function (options) { | ||
loadImage.requiresMetaData = function (options) { | ||
return options && options.meta | ||
@@ -169,2 +169,4 @@ } | ||
loadImage.global = $ | ||
if (typeof define === 'function' && define.amd) { | ||
@@ -171,0 +173,0 @@ define(function () { |
{ | ||
"name": "blueimp-load-image", | ||
"version": "3.0.0", | ||
"version": "4.0.0", | ||
"title": "JavaScript Load Image", | ||
@@ -38,3 +38,3 @@ "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.", | ||
"eslint-config-prettier": "6", | ||
"eslint-plugin-jsdoc": "22", | ||
"eslint-plugin-jsdoc": "24", | ||
"eslint-plugin-prettier": "3", | ||
@@ -41,0 +41,0 @@ "prettier": "2", |
196
README.md
@@ -42,4 +42,10 @@ # JavaScript Load Image | ||
- [Exif parser](#exif-parser) | ||
- [Exif Thumbnail](#exif-thumbnail) | ||
- [Exif IFD](#exif-ifd) | ||
- [GPSInfo IFD](#gpsinfo-ifd) | ||
- [Interoperability IFD](#interoperability-ifd) | ||
- [Exif parser options](#exif-parser-options) | ||
- [Exif writer](#exif-writer) | ||
- [IPTC parser](#iptc-parser) | ||
- [IPTC parser options](#iptc-parser-options) | ||
- [License](#license) | ||
@@ -244,3 +250,3 @@ - [Credits](#credits) | ||
canvas. | ||
Defaults to the source image width and requires `canvas: true`. | ||
Defaults to the source image width and requires `canvas: true`. | ||
@@ -251,3 +257,3 @@ ### sourceHeight | ||
canvas. | ||
Defaults to the source image height and requires `canvas: true`. | ||
Defaults to the source image height and requires `canvas: true`. | ||
@@ -257,3 +263,3 @@ ### top | ||
The top margin of the sub-rectangle of the source image. | ||
Defaults to `0` and requires `canvas: true`. | ||
Defaults to `0` and requires `canvas: true`. | ||
@@ -263,3 +269,3 @@ ### right | ||
The right margin of the sub-rectangle of the source image. | ||
Defaults to `0` and requires `canvas: true`. | ||
Defaults to `0` and requires `canvas: true`. | ||
@@ -269,3 +275,3 @@ ### bottom | ||
The bottom margin of the sub-rectangle of the source image. | ||
Defaults to `0` and requires `canvas: true`. | ||
Defaults to `0` and requires `canvas: true`. | ||
@@ -275,3 +281,3 @@ ### left | ||
The left margin of the sub-rectangle of the source image. | ||
Defaults to `0` and requires `canvas: true`. | ||
Defaults to `0` and requires `canvas: true`. | ||
@@ -281,3 +287,4 @@ ### contain | ||
Scales the image up/down to contain it in the max dimensions if set to `true`. | ||
This emulates the CSS feature [background-image: contain](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Scaling_background_images#contain). | ||
This emulates the CSS feature | ||
[background-image: contain](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Scaling_background_images#contain). | ||
@@ -288,3 +295,4 @@ ### cover | ||
if set to `true`. | ||
This emulates the CSS feature [background-image: cover](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Scaling_background_images#cover). | ||
This emulates the CSS feature | ||
[background-image: cover](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Scaling_background_images#cover). | ||
@@ -294,3 +302,3 @@ ### aspectRatio | ||
Crops the image to the given aspect ratio (e.g. `16/9`). | ||
Setting the `aspectRatio` also enables the `crop` option. | ||
Setting the `aspectRatio` also enables the `crop` option. | ||
@@ -301,5 +309,5 @@ ### pixelRatio | ||
screen. | ||
Should be set to `window.devicePixelRatio` unless the scaled image is not rendered | ||
on screen. | ||
Defaults to `1` and requires `canvas: true`. | ||
Should be set to `window.devicePixelRatio` unless the scaled image is not | ||
rendered on screen. | ||
Defaults to `1` and requires `canvas: true`. | ||
@@ -309,5 +317,5 @@ ### downsamplingRatio | ||
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 | ||
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`. | ||
Requires `canvas: true`. | ||
@@ -318,3 +326,3 @@ ### imageSmoothingEnabled | ||
[disables image smoothing](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/imageSmoothingEnabled). | ||
Defaults to `true` and requires `canvas: true`. | ||
Defaults to `true` and requires `canvas: true`. | ||
@@ -325,4 +333,4 @@ ### imageSmoothingQuality | ||
[quality of image smoothing](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/imageSmoothingQuality). | ||
Possible values: `'low'`, `'medium'`, `'high'` | ||
Defaults to `'low'` and requires `canvas: true`. | ||
Possible values: `'low'`, `'medium'`, `'high'` | ||
Defaults to `'low'` and requires `canvas: true`. | ||
@@ -332,3 +340,3 @@ ### crop | ||
Crops the image to the maxWidth/maxHeight constraints if set to `true`. | ||
Enabling the `crop` option also enables the `canvas` option. | ||
Enabling the `crop` option also enables the `canvas` option. | ||
@@ -339,17 +347,53 @@ ### orientation | ||
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 | ||
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. | ||
Setting `orientation` to an integer in the range of `2` to `8` enables the | ||
`canvas` option. | ||
Setting `orientation` to `true` enables the `canvas` and `meta` options, unless | ||
the browser supports automatic image orientation (see [browser support for image-orientation](https://caniuse.com/#feat=css-image-orientation)). | ||
Exif orientation values to correctly display the letter F: | ||
``` | ||
1 2 | ||
██████ ██████ | ||
██ ██ | ||
████ ████ | ||
██ ██ | ||
██ ██ | ||
3 4 | ||
██ ██ | ||
██ ██ | ||
████ ████ | ||
██ ██ | ||
██████ ██████ | ||
5 6 | ||
██████████ ██ | ||
██ ██ ██ ██ | ||
██ ██████████ | ||
7 8 | ||
██ ██████████ | ||
██ ██ ██ ██ | ||
██████████ ██ | ||
``` | ||
Setting `orientation` to `true` enables the `canvas` and `meta` options, unless | ||
the browser supports automatic image orientation (see | ||
[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). | ||
Setting `orientation` to an integer in the range of `2` to `8` always enables | ||
the `canvas` option and also enables the `meta` option if the browser supports | ||
automatic image orientation (again to allow reset). | ||
### meta | ||
Automatically parses the image meta data if set to `true`. | ||
The meta data is passed to the callback as part of the second argument. | ||
If the file is given as URL and the browser supports the | ||
[fetch API](https://developer.mozilla.org/en/docs/Web/API/Fetch_API), fetches | ||
the file as Blob to be able to parse the meta data. | ||
If meta data has been found, the data object passed as second argument to the | ||
callback function has additional properties (see | ||
[meta data parsing](#meta-data-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. | ||
@@ -474,5 +518,5 @@ ### canvas | ||
- `Thumbnail` | ||
- `Exif` | ||
- `GPSInfo` | ||
- `Interoperability` | ||
- `Exif` (see [Exif IFD](#exif-ifd)) | ||
- `GPSInfo` (see [GPSInfo IFD](#gpsinfo-ifd)) | ||
- `Interoperability` (see [Interoperability IFD](#interoperability-ifd)) | ||
@@ -487,3 +531,3 @@ If you also include the Load Image Exif Map library, additional tag mappings | ||
```js | ||
var flashText = data.exif.getText('Flash') // e.g.: 'Flash fired, auto mode', | ||
var flashText = data.exif.getText('Orientation') // e.g. right-top for value 6 | ||
@@ -496,5 +540,86 @@ var name = data.exif.getName(0x0112) // Orientation | ||
The Exif parser also adds additional options for the parseMetaData method, to | ||
disable certain aspects of the parser: | ||
#### Exif Thumbnail | ||
Example code displaying a thumbnail image embedded into the Exif meta data: | ||
```js | ||
loadImage( | ||
fileOrBlobOrUrl, | ||
function (img, data) { | ||
var thumbBlob = data.exif && data.exif.get('Thumbnail') | ||
if (thumbBlob) { | ||
loadImage(thumbBlob, function (thumbImage) { | ||
document.body.appendChild(thumbImage) | ||
}) | ||
} | ||
}, | ||
{ meta: true } | ||
) | ||
``` | ||
#### Exif IFD | ||
Example code displaying data from the Exif IFD (Image File Directory) that | ||
contains Exif specified TIFF tags: | ||
```js | ||
loadImage( | ||
fileOrBlobOrUrl, | ||
function (img, data) { | ||
var exifIFD = data.exif && data.exif.get('Exif') | ||
if (exifIFD) { | ||
// Map of all Exif IFD tags with their mapped names/text as keys/values: | ||
console.log(exifIFD.getAll()) | ||
// A specific Exif IFD tag value: | ||
console.log(exifIFD.get('UserComment')) | ||
} | ||
}, | ||
{ meta: true } | ||
) | ||
``` | ||
#### GPSInfo IFD | ||
Example code displaying data from the Exif IFD (Image File Directory) that | ||
contains [GPS](https://en.wikipedia.org/wiki/Global_Positioning_System) info: | ||
```js | ||
loadImage( | ||
fileOrBlobOrUrl, | ||
function (img, data) { | ||
var gpsInfo = data.exif && data.exif.get('GPSInfo') | ||
if (gpsInfo) { | ||
// Map of all GPSInfo tags with their mapped names/text as keys/values: | ||
console.log(gpsInfo.getAll()) | ||
// A specific GPSInfo tag value: | ||
console.log(gpsInfo.get('GPSLatitude')) | ||
} | ||
}, | ||
{ meta: true } | ||
) | ||
``` | ||
#### Interoperability IFD | ||
Example code displaying data from the Exif IFD (Image File Directory) that | ||
contains Interoperability data: | ||
```js | ||
loadImage( | ||
fileOrBlobOrUrl, | ||
function (img, data) { | ||
var interoperabilityData = data.exif && data.exif.get('Interoperability') | ||
if (interoperabilityData) { | ||
// The InteroperabilityIndex tag value: | ||
console.log(interoperabilityData.get('InteroperabilityIndex')) | ||
} | ||
}, | ||
{ meta: true } | ||
) | ||
``` | ||
#### Exif parser options | ||
The Exif parser adds additional options: | ||
- `disableExif`: Disables Exif parsing when `true`. | ||
@@ -615,5 +740,6 @@ - `disableExifThumbnail`: Disables parsing of Thumbnail data when `true`. | ||
The IPTC parser also adds additional options for the parseMetaData method, to | ||
disable certain aspects of the parser: | ||
#### IPTC parser options | ||
The IPTC parser adds additional options: | ||
- `disableIptc`: Disables IPTC parsing when true. | ||
@@ -620,0 +746,0 @@ - `disableIptcOffsets`: Disables storing IPTC tag offsets when `true`. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
159074
2515
777