@webex/helper-image 3.0.0-beta.9 → 3.0.0-beta.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/detect-filetype.js +3 -12
- package/dist/detect-filetype.js.map +1 -1
- package/dist/index.js +52 -90
- package/dist/index.js.map +1 -1
- package/dist/process-image.browser.js +13 -34
- package/dist/process-image.browser.js.map +1 -1
- package/dist/process-image.js +7 -24
- package/dist/process-image.js.map +1 -1
- package/package.json +6 -6
- package/src/detect-filetype.js +8 -9
- package/src/index.js +31 -37
- package/src/process-image.browser.js +77 -69
- package/src/process-image.js +38 -31
- package/test/unit/spec/index.js +58 -59
package/dist/detect-filetype.js
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
-
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
|
-
|
|
11
8
|
exports.default = detectFileType;
|
|
12
|
-
|
|
13
9
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
14
|
-
|
|
15
10
|
var _httpCore = require("@webex/http-core");
|
|
16
|
-
|
|
17
11
|
var _mime = require("mime");
|
|
18
|
-
|
|
19
12
|
/*!
|
|
20
13
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
21
14
|
*/
|
|
@@ -31,20 +24,18 @@ function detectFileType(file, logger) {
|
|
|
31
24
|
logger.info("file already has type ".concat(file.type, ". using existing file.type."));
|
|
32
25
|
return _promise.default.resolve(file.type);
|
|
33
26
|
}
|
|
34
|
-
|
|
35
27
|
if (file.mimeType) {
|
|
36
28
|
logger.info("file already has mimeType ".concat(file.type, ". using existing file.mimeType."));
|
|
37
29
|
return _promise.default.resolve(file.mimeType);
|
|
38
|
-
}
|
|
39
|
-
// buffers are expected to have names there, it'll stay here for now.
|
|
40
|
-
|
|
30
|
+
}
|
|
41
31
|
|
|
32
|
+
// This kinda belongs in http core, but since we have no guarantee that
|
|
33
|
+
// buffers are expected to have names there, it'll stay here for now.
|
|
42
34
|
return (0, _httpCore.detect)(file).then(function (type) {
|
|
43
35
|
if (type === 'application/x-msi' || type === 'application/octet-stream') {
|
|
44
36
|
logger.info("detected filetype to be ".concat(type, ". Falling back to mime.lookup"));
|
|
45
37
|
return (0, _mime.getType)(file.name);
|
|
46
38
|
}
|
|
47
|
-
|
|
48
39
|
logger.info("detected filetype to be ".concat(type, ". returning it"));
|
|
49
40
|
return type;
|
|
50
41
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["detectFileType","file","logger","type","info","resolve","mimeType","detect","then","getType","name"],"sources":["detect-filetype.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {detect} from '@webex/http-core';\nimport {getType} from 'mime';\n\n/**\n * Determines the file type of the specified file\n * @param {FileLike} file\n * @param {Object} logger\n * @returns {Promise<string>}\n */\nexport default function detectFileType(file, logger) {\n if (file.type) {\n logger.info(`file already has type ${file.type}. using existing file.type.`);\n\n return Promise.resolve(file.type);\n }\n\n if (file.mimeType) {\n logger.info(`file already has mimeType ${file.type}. using existing file.mimeType.`);\n\n return Promise.resolve(file.mimeType);\n }\n\n // This kinda belongs in http core, but since we have no guarantee that\n // buffers are expected to have names there, it'll stay here for now.\n return detect(file)
|
|
1
|
+
{"version":3,"names":["detectFileType","file","logger","type","info","resolve","mimeType","detect","then","getType","name"],"sources":["detect-filetype.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {detect} from '@webex/http-core';\nimport {getType} from 'mime';\n\n/**\n * Determines the file type of the specified file\n * @param {FileLike} file\n * @param {Object} logger\n * @returns {Promise<string>}\n */\nexport default function detectFileType(file, logger) {\n if (file.type) {\n logger.info(`file already has type ${file.type}. using existing file.type.`);\n\n return Promise.resolve(file.type);\n }\n\n if (file.mimeType) {\n logger.info(`file already has mimeType ${file.type}. using existing file.mimeType.`);\n\n return Promise.resolve(file.mimeType);\n }\n\n // This kinda belongs in http core, but since we have no guarantee that\n // buffers are expected to have names there, it'll stay here for now.\n return detect(file).then((type) => {\n if (type === 'application/x-msi' || type === 'application/octet-stream') {\n logger.info(`detected filetype to be ${type}. Falling back to mime.lookup`);\n\n return getType(file.name);\n }\n\n logger.info(`detected filetype to be ${type}. returning it`);\n\n return type;\n });\n}\n"],"mappings":";;;;;;;;;AAIA;AACA;AALA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,cAAc,CAACC,IAAI,EAAEC,MAAM,EAAE;EACnD,IAAID,IAAI,CAACE,IAAI,EAAE;IACbD,MAAM,CAACE,IAAI,iCAA0BH,IAAI,CAACE,IAAI,iCAA8B;IAE5E,OAAO,iBAAQE,OAAO,CAACJ,IAAI,CAACE,IAAI,CAAC;EACnC;EAEA,IAAIF,IAAI,CAACK,QAAQ,EAAE;IACjBJ,MAAM,CAACE,IAAI,qCAA8BH,IAAI,CAACE,IAAI,qCAAkC;IAEpF,OAAO,iBAAQE,OAAO,CAACJ,IAAI,CAACK,QAAQ,CAAC;EACvC;;EAEA;EACA;EACA,OAAO,IAAAC,gBAAM,EAACN,IAAI,CAAC,CAACO,IAAI,CAAC,UAACL,IAAI,EAAK;IACjC,IAAIA,IAAI,KAAK,mBAAmB,IAAIA,IAAI,KAAK,0BAA0B,EAAE;MACvED,MAAM,CAACE,IAAI,mCAA4BD,IAAI,mCAAgC;MAE3E,OAAO,IAAAM,aAAO,EAACR,IAAI,CAACS,IAAI,CAAC;IAC3B;IAEAR,MAAM,CAACE,IAAI,mCAA4BD,IAAI,oBAAiB;IAE5D,OAAOA,IAAI;EACb,CAAC,CAAC;AACJ"}
|
package/dist/index.js
CHANGED
|
@@ -1,69 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
-
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
|
-
|
|
11
8
|
_Object$defineProperty(exports, "detectFileType", {
|
|
12
9
|
enumerable: true,
|
|
13
10
|
get: function get() {
|
|
14
11
|
return _detectFiletype.default;
|
|
15
12
|
}
|
|
16
13
|
});
|
|
17
|
-
|
|
18
14
|
exports.orient = orient;
|
|
19
|
-
|
|
20
15
|
_Object$defineProperty(exports, "processImage", {
|
|
21
16
|
enumerable: true,
|
|
22
17
|
get: function get() {
|
|
23
18
|
return _processImage.default;
|
|
24
19
|
}
|
|
25
20
|
});
|
|
26
|
-
|
|
27
21
|
exports.readExifData = readExifData;
|
|
28
22
|
exports.updateImageOrientation = updateImageOrientation;
|
|
29
|
-
|
|
30
23
|
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
|
|
31
|
-
|
|
32
24
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
|
|
33
|
-
|
|
34
25
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
35
|
-
|
|
36
26
|
var _processImage = _interopRequireDefault(require("./process-image"));
|
|
37
|
-
|
|
38
27
|
var _detectFiletype = _interopRequireDefault(require("./detect-filetype"));
|
|
39
|
-
|
|
40
28
|
/*!
|
|
41
29
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
42
30
|
*/
|
|
43
31
|
|
|
44
32
|
/* eslint no-unused-vars: ["error", { "vars": "local" }] */
|
|
33
|
+
// eslint-disable-next-line no-redeclare
|
|
45
34
|
|
|
46
|
-
/* global FileReader */
|
|
47
35
|
var _require = require('safe-buffer'),
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
Buffer = _require.Buffer;
|
|
50
37
|
var _require2 = require('exifr/dist/lite.umd'),
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Updates the image file with exif information, required to correctly rotate the image activity
|
|
54
|
-
* @param {Object} file
|
|
55
|
-
* @param {Object} options
|
|
56
|
-
* @param {boolean} options.shouldNotAddExifData
|
|
57
|
-
* @returns {Promise<Object>}
|
|
58
|
-
*/
|
|
59
|
-
|
|
38
|
+
parse = _require2.parse;
|
|
60
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Updates the image file with exif information, required to correctly rotate the image activity
|
|
42
|
+
* @param {Object} file
|
|
43
|
+
* @param {Object} options
|
|
44
|
+
* @param {boolean} options.shouldNotAddExifData
|
|
45
|
+
* @returns {Promise<Object>}
|
|
46
|
+
*/
|
|
61
47
|
function updateImageOrientation(file) {
|
|
62
48
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
63
49
|
return new _promise.default(function (resolve) {
|
|
64
50
|
var reader = new FileReader();
|
|
65
51
|
reader.readAsArrayBuffer(file);
|
|
66
|
-
|
|
67
52
|
reader.onload = function onload() {
|
|
68
53
|
var arrayBuffer = reader.result;
|
|
69
54
|
var buf = Buffer.from(arrayBuffer);
|
|
@@ -73,84 +58,69 @@ function updateImageOrientation(file) {
|
|
|
73
58
|
if (options.shouldNotAddExifData) {
|
|
74
59
|
return buf;
|
|
75
60
|
}
|
|
76
|
-
|
|
77
61
|
return readExifData(file, buf);
|
|
78
62
|
});
|
|
79
63
|
}
|
|
80
|
-
/**
|
|
81
|
-
* Adds exif orientation information on the image file
|
|
82
|
-
* @param {Object} file
|
|
83
|
-
* @param {Object} buf
|
|
84
|
-
* @returns {Promise<ExifImage>}
|
|
85
|
-
*/
|
|
86
|
-
|
|
87
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Adds exif orientation information on the image file
|
|
67
|
+
* @param {Object} file
|
|
68
|
+
* @param {Object} buf
|
|
69
|
+
* @returns {Promise<ExifImage>}
|
|
70
|
+
*/
|
|
88
71
|
function readExifData(_x, _x2) {
|
|
89
72
|
return _readExifData.apply(this, arguments);
|
|
90
73
|
}
|
|
91
74
|
/* eslint-disable complexity */
|
|
92
|
-
|
|
93
75
|
/**
|
|
94
|
-
* Rotates/flips the image on the canvas as per exif information
|
|
95
|
-
* @param {Object} options(orientation: image exif orientation range from 1-8, img: Image object, x: start x-axis, y: start y-axis, width: width of the thumbnail, height: height of the thumbnail, ctx: canvas context)
|
|
96
|
-
* @param {Object} file
|
|
97
|
-
* @returns {Object}
|
|
98
|
-
*/
|
|
99
|
-
|
|
100
|
-
|
|
76
|
+
* Rotates/flips the image on the canvas as per exif information
|
|
77
|
+
* @param {Object} options(orientation: image exif orientation range from 1-8, img: Image object, x: start x-axis, y: start y-axis, width: width of the thumbnail, height: height of the thumbnail, ctx: canvas context)
|
|
78
|
+
* @param {Object} file
|
|
79
|
+
* @returns {Object}
|
|
80
|
+
*/
|
|
101
81
|
function _readExifData() {
|
|
102
82
|
_readExifData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(file, buf) {
|
|
103
83
|
var exifData, Orientation, ExifImageHeight, ExifImageWidth;
|
|
104
84
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
105
|
-
while (1) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
85
|
+
while (1) switch (_context.prev = _context.next) {
|
|
86
|
+
case 0:
|
|
87
|
+
if (!(file && (file.type === 'image/jpeg' || file.mimeType === 'image/jpeg'))) {
|
|
88
|
+
_context.next = 5;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
_context.next = 3;
|
|
92
|
+
return parse(buf, {
|
|
93
|
+
translateValues: false
|
|
94
|
+
});
|
|
95
|
+
case 3:
|
|
96
|
+
exifData = _context.sent;
|
|
97
|
+
if (exifData) {
|
|
98
|
+
Orientation = exifData.Orientation, ExifImageHeight = exifData.ExifImageHeight, ExifImageWidth = exifData.ExifImageWidth;
|
|
99
|
+
file.orientation = Orientation;
|
|
100
|
+
file.exifHeight = ExifImageHeight;
|
|
101
|
+
file.exifWidth = ExifImageWidth;
|
|
102
|
+
if (file.image) {
|
|
103
|
+
file.image.orientation = Orientation;
|
|
111
104
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
case 3:
|
|
119
|
-
exifData = _context.sent;
|
|
120
|
-
|
|
121
|
-
if (exifData) {
|
|
122
|
-
Orientation = exifData.Orientation, ExifImageHeight = exifData.ExifImageHeight, ExifImageWidth = exifData.ExifImageWidth;
|
|
123
|
-
file.orientation = Orientation;
|
|
124
|
-
file.exifHeight = ExifImageHeight;
|
|
125
|
-
file.exifWidth = ExifImageWidth;
|
|
126
|
-
|
|
127
|
-
if (file.image) {
|
|
128
|
-
file.image.orientation = Orientation;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
case 5:
|
|
133
|
-
return _context.abrupt("return", buf);
|
|
134
|
-
|
|
135
|
-
case 6:
|
|
136
|
-
case "end":
|
|
137
|
-
return _context.stop();
|
|
138
|
-
}
|
|
105
|
+
}
|
|
106
|
+
case 5:
|
|
107
|
+
return _context.abrupt("return", buf);
|
|
108
|
+
case 6:
|
|
109
|
+
case "end":
|
|
110
|
+
return _context.stop();
|
|
139
111
|
}
|
|
140
112
|
}, _callee);
|
|
141
113
|
}));
|
|
142
114
|
return _readExifData.apply(this, arguments);
|
|
143
115
|
}
|
|
144
|
-
|
|
145
116
|
function orient(options, file) {
|
|
146
117
|
var width = options.width,
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
118
|
+
height = options.height,
|
|
119
|
+
ctx = options.ctx,
|
|
120
|
+
img = options.img,
|
|
121
|
+
orientation = options.orientation,
|
|
122
|
+
x = options.x,
|
|
123
|
+
y = options.y;
|
|
154
124
|
if (file && file.orientation && file.orientation !== 1) {
|
|
155
125
|
// explanation of orientation:
|
|
156
126
|
// https://stackoverflow.com/questions/20600800/js-client-side-exif-orientation-rotate-and-mirror-jpeg-images
|
|
@@ -159,42 +129,34 @@ function orient(options, file) {
|
|
|
159
129
|
// flip
|
|
160
130
|
ctx.transform(-1, 0, 0, 1, width, 0);
|
|
161
131
|
break;
|
|
162
|
-
|
|
163
132
|
case 3:
|
|
164
133
|
// rotateImage180
|
|
165
134
|
ctx.transform(-1, 0, 0, -1, width, height);
|
|
166
135
|
break;
|
|
167
|
-
|
|
168
136
|
case 4:
|
|
169
137
|
// rotate180AndFlipImage
|
|
170
138
|
ctx.transform(1, 0, 0, -1, 0, height);
|
|
171
139
|
break;
|
|
172
|
-
|
|
173
140
|
case 5:
|
|
174
141
|
// rotate90AndFlipImage
|
|
175
142
|
ctx.transform(0, 1, 1, 0, 0, 0);
|
|
176
143
|
break;
|
|
177
|
-
|
|
178
144
|
case 6:
|
|
179
145
|
// rotateImage90
|
|
180
146
|
ctx.transform(0, 1, -1, 0, height, 0);
|
|
181
147
|
break;
|
|
182
|
-
|
|
183
148
|
case 7:
|
|
184
149
|
// rotateNeg90AndFlipImage
|
|
185
150
|
ctx.transform(0, -1, -1, 0, height, width);
|
|
186
151
|
break;
|
|
187
|
-
|
|
188
152
|
case 8:
|
|
189
153
|
// rotateNeg90
|
|
190
154
|
ctx.transform(0, -1, 1, 0, 0, width);
|
|
191
155
|
break;
|
|
192
|
-
|
|
193
156
|
default:
|
|
194
157
|
break;
|
|
195
158
|
}
|
|
196
159
|
}
|
|
197
|
-
|
|
198
160
|
ctx.drawImage(img, x, y, width, height);
|
|
199
161
|
}
|
|
200
162
|
/* eslint-enable complexity */
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["require","Buffer","parse","updateImageOrientation","file","options","resolve","reader","FileReader","readAsArrayBuffer","onload","arrayBuffer","result","buf","from","then","shouldNotAddExifData","readExifData","type","mimeType","translateValues","exifData","Orientation","ExifImageHeight","ExifImageWidth","orientation","exifHeight","exifWidth","image","orient","width","height","ctx","img","x","y","transform","drawImage"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint no-unused-vars: [\"error\", { \"vars\": \"local\" }] */\n
|
|
1
|
+
{"version":3,"names":["require","Buffer","parse","updateImageOrientation","file","options","resolve","reader","FileReader","readAsArrayBuffer","onload","arrayBuffer","result","buf","from","then","shouldNotAddExifData","readExifData","type","mimeType","translateValues","exifData","Orientation","ExifImageHeight","ExifImageWidth","orientation","exifHeight","exifWidth","image","orient","width","height","ctx","img","x","y","transform","drawImage"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint no-unused-vars: [\"error\", { \"vars\": \"local\" }] */\n// eslint-disable-next-line no-redeclare\n\nconst {Buffer} = require('safe-buffer');\nconst {parse} = require('exifr/dist/lite.umd');\n\n/**\n * Updates the image file with exif information, required to correctly rotate the image activity\n * @param {Object} file\n * @param {Object} options\n * @param {boolean} options.shouldNotAddExifData\n * @returns {Promise<Object>}\n */\nexport function updateImageOrientation(file, options = {}) {\n return new Promise((resolve) => {\n const reader = new FileReader();\n\n reader.readAsArrayBuffer(file);\n reader.onload = function onload() {\n const arrayBuffer = reader.result;\n const buf = Buffer.from(arrayBuffer);\n\n resolve(buf);\n };\n }).then((buf) => {\n if (options.shouldNotAddExifData) {\n return buf;\n }\n\n return readExifData(file, buf);\n });\n}\n\n/**\n * Adds exif orientation information on the image file\n * @param {Object} file\n * @param {Object} buf\n * @returns {Promise<ExifImage>}\n */\nexport async function readExifData(file, buf) {\n // For avatar images the file.type is set as image/jpeg, however for images shared in an activity file.mimeType is set as image/jpeg. Handling both conditions.\n if (file && (file.type === 'image/jpeg' || file.mimeType === 'image/jpeg')) {\n const exifData = await parse(buf, {translateValues: false});\n\n if (exifData) {\n const {Orientation, ExifImageHeight, ExifImageWidth} = exifData;\n\n file.orientation = Orientation;\n file.exifHeight = ExifImageHeight;\n file.exifWidth = ExifImageWidth;\n\n if (file.image) {\n file.image.orientation = Orientation;\n }\n }\n }\n\n return buf;\n}\n\n/* eslint-disable complexity */\n/**\n * Rotates/flips the image on the canvas as per exif information\n * @param {Object} options(orientation: image exif orientation range from 1-8, img: Image object, x: start x-axis, y: start y-axis, width: width of the thumbnail, height: height of the thumbnail, ctx: canvas context)\n * @param {Object} file\n * @returns {Object}\n */\nexport function orient(options, file) {\n const {width, height, ctx, img, orientation, x, y} = options;\n\n if (file && file.orientation && file.orientation !== 1) {\n // explanation of orientation:\n // https://stackoverflow.com/questions/20600800/js-client-side-exif-orientation-rotate-and-mirror-jpeg-images\n switch (orientation) {\n case 2:\n // flip\n ctx.transform(-1, 0, 0, 1, width, 0);\n break;\n case 3:\n // rotateImage180\n ctx.transform(-1, 0, 0, -1, width, height);\n break;\n case 4:\n // rotate180AndFlipImage\n ctx.transform(1, 0, 0, -1, 0, height);\n break;\n case 5:\n // rotate90AndFlipImage\n ctx.transform(0, 1, 1, 0, 0, 0);\n break;\n case 6:\n // rotateImage90\n ctx.transform(0, 1, -1, 0, height, 0);\n break;\n case 7:\n // rotateNeg90AndFlipImage\n ctx.transform(0, -1, -1, 0, height, width);\n break;\n case 8:\n // rotateNeg90\n ctx.transform(0, -1, 1, 0, 0, width);\n break;\n default:\n break;\n }\n }\n ctx.drawImage(img, x, y, width, height);\n}\n/* eslint-enable complexity */\n\nexport {default as processImage} from './process-image';\nexport {default as detectFileType} from './detect-filetype';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAkHA;AACA;AAnHA;AACA;AACA;;AAEA;AACA;;AAEA,eAAiBA,OAA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CAAC,CAAC,EAAE,CAAC,EAAEL,MAAM,CAAC;QACrC;MACF,KAAK,CAAC;QACJ;QACAC,GAAG,CAACI,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAC/B;MACF,KAAK,CAAC;QACJ;QACAJ,GAAG,CAACI,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAEL,MAAM,EAAE,CAAC,CAAC;QACrC;MACF,KAAK,CAAC;QACJ;QACAC,GAAG,CAACI,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAEL,MAAM,EAAED,KAAK,CAAC;QAC1C;MACF,KAAK,CAAC;QACJ;QACAE,GAAG,CAACI,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAEN,KAAK,CAAC;QACpC;MACF;QACE;IAAM;EAEZ;EACAE,GAAG,CAACK,SAAS,CAACJ,GAAG,EAAEC,CAAC,EAAEC,CAAC,EAAEL,KAAK,EAAEC,MAAM,CAAC;AACzC;AACA"}
|
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
-
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
|
-
|
|
11
8
|
exports.default = processImage;
|
|
12
|
-
|
|
13
9
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
14
|
-
|
|
15
10
|
var _pick2 = _interopRequireDefault(require("lodash/pick"));
|
|
16
|
-
|
|
17
11
|
var _index = require("./index");
|
|
18
|
-
|
|
19
12
|
/* eslint-env browser */
|
|
20
13
|
|
|
21
14
|
/**
|
|
@@ -29,14 +22,12 @@ var _index = require("./index");
|
|
|
29
22
|
*/
|
|
30
23
|
function computeDimensions(_ref, maxWidth, maxHeight) {
|
|
31
24
|
var width = _ref.width,
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
height = _ref.height;
|
|
34
26
|
if (height > width) {
|
|
35
27
|
if (height > maxHeight) {
|
|
36
28
|
width = width * maxHeight / height;
|
|
37
29
|
height = maxHeight;
|
|
38
30
|
}
|
|
39
|
-
|
|
40
31
|
if (width > maxWidth) {
|
|
41
32
|
height = height * maxWidth / width;
|
|
42
33
|
width = maxWidth;
|
|
@@ -46,18 +37,17 @@ function computeDimensions(_ref, maxWidth, maxHeight) {
|
|
|
46
37
|
height = height * maxWidth / width;
|
|
47
38
|
width = maxWidth;
|
|
48
39
|
}
|
|
49
|
-
|
|
50
40
|
if (height > maxHeight) {
|
|
51
41
|
width = width * maxHeight / height;
|
|
52
42
|
height = maxHeight;
|
|
53
43
|
}
|
|
54
44
|
}
|
|
55
|
-
|
|
56
45
|
return {
|
|
57
46
|
height: height,
|
|
58
47
|
width: width
|
|
59
48
|
};
|
|
60
49
|
}
|
|
50
|
+
|
|
61
51
|
/**
|
|
62
52
|
* Measures an image file and produces a thumbnail for it
|
|
63
53
|
* @param {Object} options
|
|
@@ -69,34 +59,27 @@ function computeDimensions(_ref, maxWidth, maxHeight) {
|
|
|
69
59
|
* @param {Boolean} options.isAvatar
|
|
70
60
|
* @returns {Promise<Array>} Buffer, Dimensions, thumbnailDimensions
|
|
71
61
|
*/
|
|
72
|
-
|
|
73
|
-
|
|
74
62
|
function processImage(_ref2) {
|
|
75
63
|
var file = _ref2.file,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
64
|
+
type = _ref2.type,
|
|
65
|
+
thumbnailMaxWidth = _ref2.thumbnailMaxWidth,
|
|
66
|
+
thumbnailMaxHeight = _ref2.thumbnailMaxHeight,
|
|
67
|
+
enableThumbnails = _ref2.enableThumbnails,
|
|
68
|
+
logger = _ref2.logger,
|
|
69
|
+
isAvatar = _ref2.isAvatar;
|
|
83
70
|
if (!type || !type.startsWith('image')) {
|
|
84
71
|
return _promise.default.resolve();
|
|
85
72
|
}
|
|
86
|
-
|
|
87
73
|
file = file instanceof Blob ? file : new Blob([file]);
|
|
88
74
|
return new _promise.default(function (resolve, reject) {
|
|
89
75
|
var img = new Image();
|
|
90
|
-
|
|
91
76
|
img.onload = function onload() {
|
|
92
77
|
resolve(img);
|
|
93
78
|
};
|
|
94
|
-
|
|
95
79
|
img.onerror = reject;
|
|
96
80
|
img.src = URL.createObjectURL(file);
|
|
97
81
|
}).then(function (img) {
|
|
98
82
|
var fileDimensions = (0, _pick2.default)(img, 'height', 'width');
|
|
99
|
-
|
|
100
83
|
if (isAvatar) {
|
|
101
84
|
// only if image is a profile avatar
|
|
102
85
|
logger.info('dimensions will be set for avatar image');
|
|
@@ -104,19 +87,18 @@ function processImage(_ref2) {
|
|
|
104
87
|
fileDimensions.height = size;
|
|
105
88
|
fileDimensions.width = size;
|
|
106
89
|
}
|
|
107
|
-
|
|
108
90
|
if (!enableThumbnails) {
|
|
109
91
|
logger.info('thumbnails not enabled');
|
|
110
92
|
return [null, fileDimensions, null];
|
|
111
93
|
}
|
|
112
|
-
|
|
113
94
|
var thumbnailDimensions = computeDimensions(fileDimensions, thumbnailMaxWidth, thumbnailMaxHeight);
|
|
114
95
|
var canvas = document.createElement('canvas');
|
|
115
96
|
var ctx = canvas.getContext('2d');
|
|
116
97
|
var width = thumbnailDimensions.width,
|
|
117
|
-
|
|
118
|
-
// https://stackoverflow.com/questions/20600800/js-client-side-exif-orientation-rotate-and-mirror-jpeg-images
|
|
98
|
+
height = thumbnailDimensions.height;
|
|
119
99
|
|
|
100
|
+
// explanation of orientation:
|
|
101
|
+
// https://stackoverflow.com/questions/20600800/js-client-side-exif-orientation-rotate-and-mirror-jpeg-images
|
|
120
102
|
if (file.orientation && file.orientation > 4) {
|
|
121
103
|
canvas.width = height;
|
|
122
104
|
canvas.height = width;
|
|
@@ -126,7 +108,6 @@ function processImage(_ref2) {
|
|
|
126
108
|
canvas.width = thumbnailDimensions.width;
|
|
127
109
|
canvas.height = thumbnailDimensions.height;
|
|
128
110
|
}
|
|
129
|
-
|
|
130
111
|
(0, _index.orient)({
|
|
131
112
|
orientation: file && file.orientation ? file.orientation : '',
|
|
132
113
|
img: img,
|
|
@@ -136,16 +117,14 @@ function processImage(_ref2) {
|
|
|
136
117
|
height: height,
|
|
137
118
|
ctx: ctx
|
|
138
119
|
}, file);
|
|
139
|
-
var parts = canvas.toDataURL('image/png').split(',');
|
|
140
|
-
|
|
120
|
+
var parts = canvas.toDataURL('image/png').split(',');
|
|
121
|
+
// Thumbnail uploads were failing with common/base64 decoding
|
|
141
122
|
var byteString = atob(parts[1]);
|
|
142
123
|
var buffer = new ArrayBuffer(byteString.length);
|
|
143
124
|
var view = new DataView(buffer);
|
|
144
|
-
|
|
145
125
|
for (var i = 0; i < byteString.length; i += 1) {
|
|
146
126
|
view.setUint8(i, byteString.charCodeAt(i));
|
|
147
127
|
}
|
|
148
|
-
|
|
149
128
|
return [buffer, fileDimensions, thumbnailDimensions];
|
|
150
129
|
});
|
|
151
130
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["computeDimensions","maxWidth","maxHeight","width","height","processImage","file","type","thumbnailMaxWidth","thumbnailMaxHeight","enableThumbnails","logger","isAvatar","startsWith","resolve","Blob","reject","img","Image","onload","onerror","src","URL","createObjectURL","then","fileDimensions","info","size","thumbnailDimensions","canvas","document","createElement","ctx","getContext","orientation","orient","x","y","parts","toDataURL","split","byteString","atob","buffer","ArrayBuffer","length","view","DataView","i","setUint8","charCodeAt"],"sources":["process-image.browser.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {pick} from 'lodash';\n\nimport {orient} from './index';\n/* eslint-env browser */\n\n/**\n * Determins the dimensions of an image\n * @param {Object} constraints\n * @param {Number} constraints.width\n * @param {Number} constraints.height\n * @param {Number} maxWidth\n * @param {Number} maxHeight\n * @returns {Object}\n */\nfunction computeDimensions({width, height}, maxWidth, maxHeight) {\n if (height > width) {\n if (height > maxHeight) {\n width = width * maxHeight / height;\n height = maxHeight;\n }\n\n if (width > maxWidth) {\n height = height * maxWidth / width;\n width = maxWidth;\n }\n }
|
|
1
|
+
{"version":3,"names":["computeDimensions","maxWidth","maxHeight","width","height","processImage","file","type","thumbnailMaxWidth","thumbnailMaxHeight","enableThumbnails","logger","isAvatar","startsWith","resolve","Blob","reject","img","Image","onload","onerror","src","URL","createObjectURL","then","fileDimensions","info","size","thumbnailDimensions","canvas","document","createElement","ctx","getContext","orientation","orient","x","y","parts","toDataURL","split","byteString","atob","buffer","ArrayBuffer","length","view","DataView","i","setUint8","charCodeAt"],"sources":["process-image.browser.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {pick} from 'lodash';\n\nimport {orient} from './index';\n/* eslint-env browser */\n\n/**\n * Determins the dimensions of an image\n * @param {Object} constraints\n * @param {Number} constraints.width\n * @param {Number} constraints.height\n * @param {Number} maxWidth\n * @param {Number} maxHeight\n * @returns {Object}\n */\nfunction computeDimensions({width, height}, maxWidth, maxHeight) {\n if (height > width) {\n if (height > maxHeight) {\n width = (width * maxHeight) / height;\n height = maxHeight;\n }\n\n if (width > maxWidth) {\n height = (height * maxWidth) / width;\n width = maxWidth;\n }\n } else {\n if (width > maxWidth) {\n height = (height * maxWidth) / width;\n width = maxWidth;\n }\n\n if (height > maxHeight) {\n width = (width * maxHeight) / height;\n height = maxHeight;\n }\n }\n\n return {height, width};\n}\n\n/**\n * Measures an image file and produces a thumbnail for it\n * @param {Object} options\n * @param {Blob|ArrayBuffer} options.file\n * @param {Number} options.thumbnailMaxWidth\n * @param {Number} options.thumbnailMaxHeight\n * @param {Boolean} options.enableThumbnails\n * @param {Object} options.logger\n * @param {Boolean} options.isAvatar\n * @returns {Promise<Array>} Buffer, Dimensions, thumbnailDimensions\n */\nexport default function processImage({\n file,\n type,\n thumbnailMaxWidth,\n thumbnailMaxHeight,\n enableThumbnails,\n logger,\n isAvatar,\n}) {\n if (!type || !type.startsWith('image')) {\n return Promise.resolve();\n }\n\n file = file instanceof Blob ? file : new Blob([file]);\n\n return new Promise((resolve, reject) => {\n const img = new Image();\n\n img.onload = function onload() {\n resolve(img);\n };\n img.onerror = reject;\n img.src = URL.createObjectURL(file);\n }).then((img) => {\n const fileDimensions = pick(img, 'height', 'width');\n\n if (isAvatar) {\n // only if image is a profile avatar\n logger.info('dimensions will be set for avatar image');\n const size =\n fileDimensions.height > fileDimensions.width ? fileDimensions.height : fileDimensions.width;\n\n fileDimensions.height = size;\n fileDimensions.width = size;\n }\n if (!enableThumbnails) {\n logger.info('thumbnails not enabled');\n\n return [null, fileDimensions, null];\n }\n const thumbnailDimensions = computeDimensions(\n fileDimensions,\n thumbnailMaxWidth,\n thumbnailMaxHeight\n );\n\n const canvas = document.createElement('canvas');\n const ctx = canvas.getContext('2d');\n const {width, height} = thumbnailDimensions;\n\n // explanation of orientation:\n // https://stackoverflow.com/questions/20600800/js-client-side-exif-orientation-rotate-and-mirror-jpeg-images\n if (file.orientation && file.orientation > 4) {\n canvas.width = height;\n canvas.height = width;\n thumbnailDimensions.width = height;\n thumbnailDimensions.height = width;\n } else {\n canvas.width = thumbnailDimensions.width;\n canvas.height = thumbnailDimensions.height;\n }\n\n orient(\n {\n orientation: file && file.orientation ? file.orientation : '',\n img,\n x: 0,\n y: 0,\n width,\n height,\n ctx,\n },\n file\n );\n\n const parts = canvas.toDataURL('image/png').split(',');\n // Thumbnail uploads were failing with common/base64 decoding\n const byteString = atob(parts[1]);\n\n const buffer = new ArrayBuffer(byteString.length);\n const view = new DataView(buffer);\n\n for (let i = 0; i < byteString.length; i += 1) {\n view.setUint8(i, byteString.charCodeAt(i));\n }\n\n return [buffer, fileDimensions, thumbnailDimensions];\n });\n}\n"],"mappings":";;;;;;;;;;AAMA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,iBAAiB,OAAkBC,QAAQ,EAAEC,SAAS,EAAE;EAAA,IAArCC,KAAK,QAALA,KAAK;IAAEC,MAAM,QAANA,MAAM;EACvC,IAAIA,MAAM,GAAGD,KAAK,EAAE;IAClB,IAAIC,MAAM,GAAGF,SAAS,EAAE;MACtBC,KAAK,GAAIA,KAAK,GAAGD,SAAS,GAAIE,MAAM;MACpCA,MAAM,GAAGF,SAAS;IACpB;IAEA,IAAIC,KAAK,GAAGF,QAAQ,EAAE;MACpBG,MAAM,GAAIA,MAAM,GAAGH,QAAQ,GAAIE,KAAK;MACpCA,KAAK,GAAGF,QAAQ;IAClB;EACF,CAAC,MAAM;IACL,IAAIE,KAAK,GAAGF,QAAQ,EAAE;MACpBG,MAAM,GAAIA,MAAM,GAAGH,QAAQ,GAAIE,KAAK;MACpCA,KAAK,GAAGF,QAAQ;IAClB;IAEA,IAAIG,MAAM,GAAGF,SAAS,EAAE;MACtBC,KAAK,GAAIA,KAAK,GAAGD,SAAS,GAAIE,MAAM;MACpCA,MAAM,GAAGF,SAAS;IACpB;EACF;EAEA,OAAO;IAACE,MAAM,EAANA,MAAM;IAAED,KAAK,EAALA;EAAK,CAAC;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASE,YAAY,QAQjC;EAAA,IAPDC,IAAI,SAAJA,IAAI;IACJC,IAAI,SAAJA,IAAI;IACJC,iBAAiB,SAAjBA,iBAAiB;IACjBC,kBAAkB,SAAlBA,kBAAkB;IAClBC,gBAAgB,SAAhBA,gBAAgB;IAChBC,MAAM,SAANA,MAAM;IACNC,QAAQ,SAARA,QAAQ;EAER,IAAI,CAACL,IAAI,IAAI,CAACA,IAAI,CAACM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