ngx-image-cropper 5.0.0 → 6.0.2
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/README.md +1 -0
- package/esm2020/lib/component/image-cropper.component.mjs +540 -0
- package/esm2020/lib/image-cropper.module.mjs +26 -0
- package/esm2020/lib/interfaces/cropper-options.interface.mjs +2 -0
- package/esm2020/lib/interfaces/cropper-position.interface.mjs +2 -0
- package/esm2020/lib/interfaces/cropper.settings.mjs +50 -0
- package/esm2020/lib/interfaces/dimensions.interface.mjs +2 -0
- package/esm2020/lib/interfaces/exif-transform.interface.mjs +2 -0
- package/esm2020/lib/interfaces/image-cropped-event.interface.mjs +2 -0
- package/esm2020/lib/interfaces/image-transform.interface.mjs +2 -0
- package/esm2020/lib/interfaces/index.mjs +2 -0
- package/esm2020/lib/interfaces/loaded-image.interface.mjs +2 -0
- package/esm2020/lib/interfaces/move-start.interface.mjs +7 -0
- package/esm2020/lib/services/crop.service.mjs +117 -0
- package/esm2020/lib/services/cropper-position.service.mjs +201 -0
- package/esm2020/lib/services/load-image.service.mjs +168 -0
- package/esm2020/lib/utils/blob.utils.mjs +12 -0
- package/esm2020/lib/utils/exif.utils.mjs +89 -0
- package/esm2020/lib/utils/hammer.utils.mjs +2 -0
- package/esm2020/lib/utils/keyboard.utils.mjs +40 -0
- package/esm2020/lib/utils/resize.utils.mjs +75 -0
- package/esm2020/ngx-image-cropper.mjs +5 -0
- package/esm2020/public-api.mjs +6 -0
- package/fesm2015/{ngx-image-cropper.js → ngx-image-cropper.mjs} +251 -1035
- package/fesm2015/ngx-image-cropper.mjs.map +1 -0
- package/fesm2020/ngx-image-cropper.mjs +1315 -0
- package/fesm2020/ngx-image-cropper.mjs.map +1 -0
- package/lib/component/image-cropper.component.d.ts +12 -9
- package/lib/image-cropper.module.d.ts +6 -0
- package/lib/interfaces/cropper.settings.d.ts +1 -1
- package/lib/services/crop.service.d.ts +3 -0
- package/lib/services/cropper-position.service.d.ts +3 -0
- package/lib/services/load-image.service.d.ts +3 -0
- package/lib/utils/hammer.utils.d.ts +1 -1
- package/ngx-image-cropper.d.ts +1 -3
- package/package.json +24 -13
- package/bundles/ngx-image-cropper.umd.js +0 -2418
- package/bundles/ngx-image-cropper.umd.js.map +0 -1
- package/bundles/ngx-image-cropper.umd.min.js +0 -16
- package/bundles/ngx-image-cropper.umd.min.js.map +0 -1
- package/esm2015/lib/component/image-cropper.component.js +0 -827
- package/esm2015/lib/image-cropper.module.js +0 -24
- package/esm2015/lib/interfaces/cropper-options.interface.js +0 -56
- package/esm2015/lib/interfaces/cropper-position.interface.js +0 -20
- package/esm2015/lib/interfaces/cropper.settings.js +0 -140
- package/esm2015/lib/interfaces/dimensions.interface.js +0 -16
- package/esm2015/lib/interfaces/exif-transform.interface.js +0 -16
- package/esm2015/lib/interfaces/image-cropped-event.interface.js +0 -24
- package/esm2015/lib/interfaces/image-transform.interface.js +0 -20
- package/esm2015/lib/interfaces/index.js +0 -6
- package/esm2015/lib/interfaces/loaded-image.interface.js +0 -18
- package/esm2015/lib/interfaces/move-start.interface.js +0 -37
- package/esm2015/lib/services/crop.service.js +0 -176
- package/esm2015/lib/services/cropper-position.service.js +0 -259
- package/esm2015/lib/services/load-image.service.js +0 -304
- package/esm2015/lib/utils/blob.utils.js +0 -26
- package/esm2015/lib/utils/exif.utils.js +0 -128
- package/esm2015/lib/utils/hammer.utils.js +0 -29
- package/esm2015/lib/utils/keyboard.utils.js +0 -58
- package/esm2015/lib/utils/resize.utils.js +0 -116
- package/esm2015/ngx-image-cropper.js +0 -13
- package/esm2015/public-api.js +0 -11
- package/fesm2015/ngx-image-cropper.js.map +0 -1
- package/ngx-image-cropper.metadata.json +0 -1
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, EventEmitter, isDevMode, Component, ChangeDetectionStrategy, ViewChild, Input, HostBinding, Output, HostListener, NgModule } from '@angular/core';
|
|
3
3
|
import { __awaiter } from 'tslib';
|
|
4
|
+
import * as i4 from '@angular/platform-browser';
|
|
5
|
+
import * as i5 from '@angular/common';
|
|
4
6
|
import { CommonModule } from '@angular/common';
|
|
5
7
|
|
|
6
|
-
/**
|
|
7
|
-
* @fileoverview added by tsickle
|
|
8
|
-
* Generated from: lib/interfaces/cropper.settings.ts
|
|
9
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
10
|
-
*/
|
|
11
8
|
class CropperSettings {
|
|
12
9
|
constructor() {
|
|
13
10
|
// From options
|
|
@@ -29,7 +26,6 @@ class CropperSettings {
|
|
|
29
26
|
this.onlyScaleDown = false;
|
|
30
27
|
this.imageQuality = 92;
|
|
31
28
|
this.autoCrop = true;
|
|
32
|
-
this.backgroundColor = undefined;
|
|
33
29
|
this.containWithinAspectRatio = false;
|
|
34
30
|
this.hideResizeSquares = false;
|
|
35
31
|
this.alignImage = 'center';
|
|
@@ -40,227 +36,114 @@ class CropperSettings {
|
|
|
40
36
|
this.cropperScaledMaxHeight = 20;
|
|
41
37
|
this.stepSize = this.initialStepSize;
|
|
42
38
|
}
|
|
43
|
-
/**
|
|
44
|
-
* @param {?} options
|
|
45
|
-
* @return {?}
|
|
46
|
-
*/
|
|
47
39
|
setOptions(options) {
|
|
48
40
|
Object.keys(options)
|
|
49
|
-
.filter((
|
|
50
|
-
|
|
51
|
-
* @return {?}
|
|
52
|
-
*/
|
|
53
|
-
(k) => k in this))
|
|
54
|
-
.forEach((/**
|
|
55
|
-
* @param {?} k
|
|
56
|
-
* @return {?}
|
|
57
|
-
*/
|
|
58
|
-
(k) => this[k] = options[k]));
|
|
41
|
+
.filter((k) => k in this)
|
|
42
|
+
.forEach((k) => this[k] = options[k]);
|
|
59
43
|
this.validateOptions();
|
|
60
44
|
}
|
|
61
|
-
/**
|
|
62
|
-
* @param {?} changes
|
|
63
|
-
* @return {?}
|
|
64
|
-
*/
|
|
65
45
|
setOptionsFromChanges(changes) {
|
|
66
46
|
Object.keys(changes)
|
|
67
|
-
.filter((
|
|
68
|
-
|
|
69
|
-
* @return {?}
|
|
70
|
-
*/
|
|
71
|
-
(k) => k in this))
|
|
72
|
-
.forEach((/**
|
|
73
|
-
* @param {?} k
|
|
74
|
-
* @return {?}
|
|
75
|
-
*/
|
|
76
|
-
(k) => this[k] = changes[k].currentValue));
|
|
47
|
+
.filter((k) => k in this)
|
|
48
|
+
.forEach((k) => this[k] = changes[k].currentValue);
|
|
77
49
|
this.validateOptions();
|
|
78
50
|
}
|
|
79
|
-
/**
|
|
80
|
-
* @private
|
|
81
|
-
* @return {?}
|
|
82
|
-
*/
|
|
83
51
|
validateOptions() {
|
|
84
52
|
if (this.maintainAspectRatio && !this.aspectRatio) {
|
|
85
53
|
throw new Error('`aspectRatio` should > 0 when `maintainAspectRatio` is enabled');
|
|
86
54
|
}
|
|
87
55
|
}
|
|
88
56
|
}
|
|
89
|
-
if (false) {
|
|
90
|
-
/** @type {?} */
|
|
91
|
-
CropperSettings.prototype.format;
|
|
92
|
-
/** @type {?} */
|
|
93
|
-
CropperSettings.prototype.maintainAspectRatio;
|
|
94
|
-
/** @type {?} */
|
|
95
|
-
CropperSettings.prototype.transform;
|
|
96
|
-
/** @type {?} */
|
|
97
|
-
CropperSettings.prototype.aspectRatio;
|
|
98
|
-
/** @type {?} */
|
|
99
|
-
CropperSettings.prototype.resizeToWidth;
|
|
100
|
-
/** @type {?} */
|
|
101
|
-
CropperSettings.prototype.resizeToHeight;
|
|
102
|
-
/** @type {?} */
|
|
103
|
-
CropperSettings.prototype.cropperMinWidth;
|
|
104
|
-
/** @type {?} */
|
|
105
|
-
CropperSettings.prototype.cropperMinHeight;
|
|
106
|
-
/** @type {?} */
|
|
107
|
-
CropperSettings.prototype.cropperMaxHeight;
|
|
108
|
-
/** @type {?} */
|
|
109
|
-
CropperSettings.prototype.cropperMaxWidth;
|
|
110
|
-
/** @type {?} */
|
|
111
|
-
CropperSettings.prototype.cropperStaticWidth;
|
|
112
|
-
/** @type {?} */
|
|
113
|
-
CropperSettings.prototype.cropperStaticHeight;
|
|
114
|
-
/** @type {?} */
|
|
115
|
-
CropperSettings.prototype.canvasRotation;
|
|
116
|
-
/** @type {?} */
|
|
117
|
-
CropperSettings.prototype.initialStepSize;
|
|
118
|
-
/** @type {?} */
|
|
119
|
-
CropperSettings.prototype.roundCropper;
|
|
120
|
-
/** @type {?} */
|
|
121
|
-
CropperSettings.prototype.onlyScaleDown;
|
|
122
|
-
/** @type {?} */
|
|
123
|
-
CropperSettings.prototype.imageQuality;
|
|
124
|
-
/** @type {?} */
|
|
125
|
-
CropperSettings.prototype.autoCrop;
|
|
126
|
-
/** @type {?} */
|
|
127
|
-
CropperSettings.prototype.backgroundColor;
|
|
128
|
-
/** @type {?} */
|
|
129
|
-
CropperSettings.prototype.containWithinAspectRatio;
|
|
130
|
-
/** @type {?} */
|
|
131
|
-
CropperSettings.prototype.hideResizeSquares;
|
|
132
|
-
/** @type {?} */
|
|
133
|
-
CropperSettings.prototype.alignImage;
|
|
134
|
-
/** @type {?} */
|
|
135
|
-
CropperSettings.prototype.cropperScaledMinWidth;
|
|
136
|
-
/** @type {?} */
|
|
137
|
-
CropperSettings.prototype.cropperScaledMinHeight;
|
|
138
|
-
/** @type {?} */
|
|
139
|
-
CropperSettings.prototype.cropperScaledMaxWidth;
|
|
140
|
-
/** @type {?} */
|
|
141
|
-
CropperSettings.prototype.cropperScaledMaxHeight;
|
|
142
|
-
/** @type {?} */
|
|
143
|
-
CropperSettings.prototype.stepSize;
|
|
144
|
-
}
|
|
145
57
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
58
|
+
var MoveTypes;
|
|
59
|
+
(function (MoveTypes) {
|
|
60
|
+
MoveTypes["Move"] = "move";
|
|
61
|
+
MoveTypes["Resize"] = "resize";
|
|
62
|
+
MoveTypes["Pinch"] = "pinch";
|
|
63
|
+
})(MoveTypes || (MoveTypes = {}));
|
|
64
|
+
|
|
65
|
+
function getPositionForKey(key) {
|
|
66
|
+
switch (key) {
|
|
67
|
+
case 'ArrowUp':
|
|
68
|
+
return 'top';
|
|
69
|
+
case 'ArrowRight':
|
|
70
|
+
return 'right';
|
|
71
|
+
case 'ArrowDown':
|
|
72
|
+
return 'bottom';
|
|
73
|
+
case 'ArrowLeft':
|
|
74
|
+
default:
|
|
75
|
+
return 'left';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function getInvertedPositionForKey(key) {
|
|
79
|
+
switch (key) {
|
|
80
|
+
case 'ArrowUp':
|
|
81
|
+
return 'bottom';
|
|
82
|
+
case 'ArrowRight':
|
|
83
|
+
return 'left';
|
|
84
|
+
case 'ArrowDown':
|
|
85
|
+
return 'top';
|
|
86
|
+
case 'ArrowLeft':
|
|
87
|
+
default:
|
|
88
|
+
return 'right';
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function getEventForKey(key, stepSize) {
|
|
92
|
+
switch (key) {
|
|
93
|
+
case 'ArrowUp':
|
|
94
|
+
return { clientX: 0, clientY: stepSize * -1 };
|
|
95
|
+
case 'ArrowRight':
|
|
96
|
+
return { clientX: stepSize, clientY: 0 };
|
|
97
|
+
case 'ArrowDown':
|
|
98
|
+
return { clientX: 0, clientY: stepSize };
|
|
99
|
+
case 'ArrowLeft':
|
|
100
|
+
default:
|
|
101
|
+
return { clientX: stepSize * -1, clientY: 0 };
|
|
102
|
+
}
|
|
174
103
|
}
|
|
175
|
-
/** @enum {string} */
|
|
176
|
-
const MoveTypes = {
|
|
177
|
-
Move: "move",
|
|
178
|
-
Resize: "resize",
|
|
179
|
-
Pinch: "pinch",
|
|
180
|
-
};
|
|
181
104
|
|
|
182
|
-
/**
|
|
183
|
-
* @fileoverview added by tsickle
|
|
184
|
-
* Generated from: lib/utils/resize.utils.ts
|
|
185
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
186
|
-
*/
|
|
187
105
|
/*
|
|
188
106
|
* Hermite resize - fast image resize/resample using Hermite filter.
|
|
189
107
|
* https://github.com/viliusle/Hermite-resize
|
|
190
108
|
*/
|
|
191
|
-
/**
|
|
192
|
-
* @param {?} canvas
|
|
193
|
-
* @param {?} width
|
|
194
|
-
* @param {?} height
|
|
195
|
-
* @return {?}
|
|
196
|
-
*/
|
|
197
109
|
function resizeCanvas(canvas, width, height) {
|
|
198
|
-
/** @type {?} */
|
|
199
110
|
const width_source = canvas.width;
|
|
200
|
-
/** @type {?} */
|
|
201
111
|
const height_source = canvas.height;
|
|
202
112
|
width = Math.round(width);
|
|
203
113
|
height = Math.round(height);
|
|
204
|
-
/** @type {?} */
|
|
205
114
|
const ratio_w = width_source / width;
|
|
206
|
-
/** @type {?} */
|
|
207
115
|
const ratio_h = height_source / height;
|
|
208
|
-
/** @type {?} */
|
|
209
116
|
const ratio_w_half = Math.ceil(ratio_w / 2);
|
|
210
|
-
/** @type {?} */
|
|
211
117
|
const ratio_h_half = Math.ceil(ratio_h / 2);
|
|
212
|
-
/** @type {?} */
|
|
213
118
|
const ctx = canvas.getContext('2d');
|
|
214
119
|
if (ctx) {
|
|
215
|
-
/** @type {?} */
|
|
216
120
|
const img = ctx.getImageData(0, 0, width_source, height_source);
|
|
217
|
-
/** @type {?} */
|
|
218
121
|
const img2 = ctx.createImageData(width, height);
|
|
219
|
-
/** @type {?} */
|
|
220
122
|
const data = img.data;
|
|
221
|
-
/** @type {?} */
|
|
222
123
|
const data2 = img2.data;
|
|
223
124
|
for (let j = 0; j < height; j++) {
|
|
224
125
|
for (let i = 0; i < width; i++) {
|
|
225
|
-
/** @type {?} */
|
|
226
126
|
const x2 = (i + j * width) * 4;
|
|
227
|
-
/** @type {?} */
|
|
228
127
|
const center_y = j * ratio_h;
|
|
229
|
-
/** @type {?} */
|
|
230
128
|
let weight = 0;
|
|
231
|
-
/** @type {?} */
|
|
232
129
|
let weights = 0;
|
|
233
|
-
/** @type {?} */
|
|
234
130
|
let weights_alpha = 0;
|
|
235
|
-
/** @type {?} */
|
|
236
131
|
let gx_r = 0;
|
|
237
|
-
/** @type {?} */
|
|
238
132
|
let gx_g = 0;
|
|
239
|
-
/** @type {?} */
|
|
240
133
|
let gx_b = 0;
|
|
241
|
-
/** @type {?} */
|
|
242
134
|
let gx_a = 0;
|
|
243
|
-
/** @type {?} */
|
|
244
135
|
const xx_start = Math.floor(i * ratio_w);
|
|
245
|
-
/** @type {?} */
|
|
246
136
|
const yy_start = Math.floor(j * ratio_h);
|
|
247
|
-
/** @type {?} */
|
|
248
137
|
let xx_stop = Math.ceil((i + 1) * ratio_w);
|
|
249
|
-
/** @type {?} */
|
|
250
138
|
let yy_stop = Math.ceil((j + 1) * ratio_h);
|
|
251
139
|
xx_stop = Math.min(xx_stop, width_source);
|
|
252
140
|
yy_stop = Math.min(yy_stop, height_source);
|
|
253
141
|
for (let yy = yy_start; yy < yy_stop; yy++) {
|
|
254
|
-
/** @type {?} */
|
|
255
142
|
const dy = Math.abs(center_y - yy) / ratio_h_half;
|
|
256
|
-
/** @type {?} */
|
|
257
143
|
const center_x = i * ratio_w;
|
|
258
|
-
|
|
259
|
-
const w0 = dy * dy;
|
|
144
|
+
const w0 = dy * dy; //pre-calc part of w
|
|
260
145
|
for (let xx = xx_start; xx < xx_stop; xx++) {
|
|
261
|
-
/** @type {?} */
|
|
262
146
|
const dx = Math.abs(center_x - xx) / ratio_w_half;
|
|
263
|
-
/** @type {?} */
|
|
264
147
|
const w = Math.sqrt(w0 + dx * dx);
|
|
265
148
|
if (w >= 1) {
|
|
266
149
|
//pixel too far
|
|
@@ -268,7 +151,6 @@ function resizeCanvas(canvas, width, height) {
|
|
|
268
151
|
}
|
|
269
152
|
//hermite filter
|
|
270
153
|
weight = 2 * w * w * w - 3 * w * w + 1;
|
|
271
|
-
/** @type {?} */
|
|
272
154
|
const pos_x = 4 * (xx + yy * width_source);
|
|
273
155
|
//alpha
|
|
274
156
|
gx_a += weight * data[pos_x + 3];
|
|
@@ -295,50 +177,29 @@ function resizeCanvas(canvas, width, height) {
|
|
|
295
177
|
}
|
|
296
178
|
}
|
|
297
179
|
|
|
298
|
-
/**
|
|
299
|
-
* @fileoverview added by tsickle
|
|
300
|
-
* Generated from: lib/services/crop.service.ts
|
|
301
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
302
|
-
*/
|
|
303
180
|
class CropService {
|
|
304
|
-
/**
|
|
305
|
-
* @param {?} sourceImage
|
|
306
|
-
* @param {?} loadedImage
|
|
307
|
-
* @param {?} cropper
|
|
308
|
-
* @param {?} settings
|
|
309
|
-
* @return {?}
|
|
310
|
-
*/
|
|
311
181
|
crop(sourceImage, loadedImage, cropper, settings) {
|
|
312
|
-
/** @type {?} */
|
|
313
182
|
const imagePosition = this.getImagePosition(sourceImage, loadedImage, cropper, settings);
|
|
314
|
-
/** @type {?} */
|
|
315
183
|
const width = imagePosition.x2 - imagePosition.x1;
|
|
316
|
-
/** @type {?} */
|
|
317
184
|
const height = imagePosition.y2 - imagePosition.y1;
|
|
318
|
-
|
|
319
|
-
const cropCanvas = (/** @type {?} */ (document.createElement('canvas')));
|
|
185
|
+
const cropCanvas = document.createElement('canvas');
|
|
320
186
|
cropCanvas.width = width;
|
|
321
187
|
cropCanvas.height = height;
|
|
322
|
-
/** @type {?} */
|
|
323
188
|
const ctx = cropCanvas.getContext('2d');
|
|
324
189
|
if (!ctx) {
|
|
325
|
-
return;
|
|
190
|
+
return null;
|
|
326
191
|
}
|
|
327
192
|
if (settings.backgroundColor != null) {
|
|
328
193
|
ctx.fillStyle = settings.backgroundColor;
|
|
329
194
|
ctx.fillRect(0, 0, width, height);
|
|
330
195
|
}
|
|
331
|
-
/** @type {?} */
|
|
332
196
|
const scaleX = (settings.transform.scale || 1) * (settings.transform.flipH ? -1 : 1);
|
|
333
|
-
/** @type {?} */
|
|
334
197
|
const scaleY = (settings.transform.scale || 1) * (settings.transform.flipV ? -1 : 1);
|
|
335
|
-
/** @type {?} */
|
|
336
198
|
const transformedImage = loadedImage.transformed;
|
|
337
199
|
ctx.setTransform(scaleX, 0, 0, scaleY, transformedImage.size.width / 2, transformedImage.size.height / 2);
|
|
338
200
|
ctx.translate(-imagePosition.x1 / scaleX, -imagePosition.y1 / scaleY);
|
|
339
201
|
ctx.rotate((settings.transform.rotate || 0) * Math.PI / 180);
|
|
340
202
|
ctx.drawImage(transformedImage.image, -transformedImage.size.width / 2, -transformedImage.size.height / 2);
|
|
341
|
-
/** @type {?} */
|
|
342
203
|
const output = {
|
|
343
204
|
width, height,
|
|
344
205
|
imagePosition,
|
|
@@ -347,7 +208,6 @@ class CropService {
|
|
|
347
208
|
if (settings.containWithinAspectRatio) {
|
|
348
209
|
output.offsetImagePosition = this.getOffsetImagePosition(sourceImage, loadedImage, cropper, settings);
|
|
349
210
|
}
|
|
350
|
-
/** @type {?} */
|
|
351
211
|
const resizeRatio = this.getResizeRatio(width, height, settings);
|
|
352
212
|
if (resizeRatio !== 1) {
|
|
353
213
|
output.width = Math.round(width * resizeRatio);
|
|
@@ -359,20 +219,9 @@ class CropService {
|
|
|
359
219
|
output.base64 = cropCanvas.toDataURL('image/' + settings.format, this.getQuality(settings));
|
|
360
220
|
return output;
|
|
361
221
|
}
|
|
362
|
-
/**
|
|
363
|
-
* @private
|
|
364
|
-
* @param {?} sourceImage
|
|
365
|
-
* @param {?} loadedImage
|
|
366
|
-
* @param {?} cropper
|
|
367
|
-
* @param {?} settings
|
|
368
|
-
* @return {?}
|
|
369
|
-
*/
|
|
370
222
|
getImagePosition(sourceImage, loadedImage, cropper, settings) {
|
|
371
|
-
/** @type {?} */
|
|
372
223
|
const sourceImageElement = sourceImage.nativeElement;
|
|
373
|
-
/** @type {?} */
|
|
374
224
|
const ratio = loadedImage.transformed.size.width / sourceImageElement.offsetWidth;
|
|
375
|
-
/** @type {?} */
|
|
376
225
|
const out = {
|
|
377
226
|
x1: Math.round(cropper.x1 * ratio),
|
|
378
227
|
y1: Math.round(cropper.y1 * ratio),
|
|
@@ -387,24 +236,11 @@ class CropService {
|
|
|
387
236
|
}
|
|
388
237
|
return out;
|
|
389
238
|
}
|
|
390
|
-
/**
|
|
391
|
-
* @private
|
|
392
|
-
* @param {?} sourceImage
|
|
393
|
-
* @param {?} loadedImage
|
|
394
|
-
* @param {?} cropper
|
|
395
|
-
* @param {?} settings
|
|
396
|
-
* @return {?}
|
|
397
|
-
*/
|
|
398
239
|
getOffsetImagePosition(sourceImage, loadedImage, cropper, settings) {
|
|
399
|
-
/** @type {?} */
|
|
400
240
|
const canvasRotation = settings.canvasRotation + loadedImage.exifTransform.rotate;
|
|
401
|
-
/** @type {?} */
|
|
402
241
|
const sourceImageElement = sourceImage.nativeElement;
|
|
403
|
-
/** @type {?} */
|
|
404
242
|
const ratio = loadedImage.transformed.size.width / sourceImageElement.offsetWidth;
|
|
405
|
-
/** @type {?} */
|
|
406
243
|
let offsetX;
|
|
407
|
-
/** @type {?} */
|
|
408
244
|
let offsetY;
|
|
409
245
|
if (canvasRotation % 2) {
|
|
410
246
|
offsetX = (loadedImage.transformed.size.width - loadedImage.original.size.height) / 2;
|
|
@@ -414,7 +250,6 @@ class CropService {
|
|
|
414
250
|
offsetX = (loadedImage.transformed.size.width - loadedImage.original.size.width) / 2;
|
|
415
251
|
offsetY = (loadedImage.transformed.size.height - loadedImage.original.size.height) / 2;
|
|
416
252
|
}
|
|
417
|
-
/** @type {?} */
|
|
418
253
|
const out = {
|
|
419
254
|
x1: Math.round(cropper.x1 * ratio) - offsetX,
|
|
420
255
|
y1: Math.round(cropper.y1 * ratio) - offsetY,
|
|
@@ -429,18 +264,9 @@ class CropService {
|
|
|
429
264
|
}
|
|
430
265
|
return out;
|
|
431
266
|
}
|
|
432
|
-
/**
|
|
433
|
-
* @param {?} width
|
|
434
|
-
* @param {?} height
|
|
435
|
-
* @param {?} settings
|
|
436
|
-
* @return {?}
|
|
437
|
-
*/
|
|
438
267
|
getResizeRatio(width, height, settings) {
|
|
439
|
-
/** @type {?} */
|
|
440
268
|
const ratioWidth = settings.resizeToWidth / width;
|
|
441
|
-
/** @type {?} */
|
|
442
269
|
const ratioHeight = settings.resizeToHeight / height;
|
|
443
|
-
/** @type {?} */
|
|
444
270
|
const ratios = new Array();
|
|
445
271
|
if (settings.resizeToWidth > 0) {
|
|
446
272
|
ratios.push(ratioWidth);
|
|
@@ -448,43 +274,28 @@ class CropService {
|
|
|
448
274
|
if (settings.resizeToHeight > 0) {
|
|
449
275
|
ratios.push(ratioHeight);
|
|
450
276
|
}
|
|
451
|
-
/** @type {?} */
|
|
452
277
|
const result = ratios.length === 0 ? 1 : Math.min(...ratios);
|
|
453
278
|
if (result > 1 && !settings.onlyScaleDown) {
|
|
454
279
|
return result;
|
|
455
280
|
}
|
|
456
281
|
return Math.min(result, 1);
|
|
457
282
|
}
|
|
458
|
-
/**
|
|
459
|
-
* @param {?} settings
|
|
460
|
-
* @return {?}
|
|
461
|
-
*/
|
|
462
283
|
getQuality(settings) {
|
|
463
284
|
return Math.min(1, Math.max(0, settings.imageQuality / 100));
|
|
464
285
|
}
|
|
465
286
|
}
|
|
466
|
-
CropService
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
287
|
+
CropService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: CropService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
288
|
+
CropService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: CropService, providedIn: 'root' });
|
|
289
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: CropService, decorators: [{
|
|
290
|
+
type: Injectable,
|
|
291
|
+
args: [{ providedIn: 'root' }]
|
|
292
|
+
}] });
|
|
470
293
|
|
|
471
|
-
/**
|
|
472
|
-
* @fileoverview added by tsickle
|
|
473
|
-
* Generated from: lib/services/cropper-position.service.ts
|
|
474
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
475
|
-
*/
|
|
476
294
|
class CropperPositionService {
|
|
477
|
-
/**
|
|
478
|
-
* @param {?} sourceImage
|
|
479
|
-
* @param {?} cropperPosition
|
|
480
|
-
* @param {?} settings
|
|
481
|
-
* @return {?}
|
|
482
|
-
*/
|
|
483
295
|
resetCropperPosition(sourceImage, cropperPosition, settings) {
|
|
484
296
|
if (!(sourceImage === null || sourceImage === void 0 ? void 0 : sourceImage.nativeElement)) {
|
|
485
297
|
return;
|
|
486
298
|
}
|
|
487
|
-
/** @type {?} */
|
|
488
299
|
const sourceImageElement = sourceImage.nativeElement;
|
|
489
300
|
if (settings.cropperStaticHeight && settings.cropperStaticWidth) {
|
|
490
301
|
cropperPosition.x1 = 0;
|
|
@@ -495,9 +306,7 @@ class CropperPositionService {
|
|
|
495
306
|
settings.cropperStaticHeight : sourceImageElement.offsetHeight;
|
|
496
307
|
}
|
|
497
308
|
else {
|
|
498
|
-
/** @type {?} */
|
|
499
309
|
const cropperWidth = Math.min(settings.cropperScaledMaxWidth, sourceImageElement.offsetWidth);
|
|
500
|
-
/** @type {?} */
|
|
501
310
|
const cropperHeight = Math.min(settings.cropperScaledMaxHeight, sourceImageElement.offsetHeight);
|
|
502
311
|
if (!settings.maintainAspectRatio) {
|
|
503
312
|
cropperPosition.x1 = 0;
|
|
@@ -508,7 +317,6 @@ class CropperPositionService {
|
|
|
508
317
|
else if (sourceImageElement.offsetWidth / settings.aspectRatio < sourceImageElement.offsetHeight) {
|
|
509
318
|
cropperPosition.x1 = 0;
|
|
510
319
|
cropperPosition.x2 = cropperWidth;
|
|
511
|
-
/** @type {?} */
|
|
512
320
|
const cropperHeightWithAspectRatio = cropperWidth / settings.aspectRatio;
|
|
513
321
|
cropperPosition.y1 = (sourceImageElement.offsetHeight - cropperHeightWithAspectRatio) / 2;
|
|
514
322
|
cropperPosition.y2 = cropperPosition.y1 + cropperHeightWithAspectRatio;
|
|
@@ -516,41 +324,22 @@ class CropperPositionService {
|
|
|
516
324
|
else {
|
|
517
325
|
cropperPosition.y1 = 0;
|
|
518
326
|
cropperPosition.y2 = cropperHeight;
|
|
519
|
-
/** @type {?} */
|
|
520
327
|
const cropperWidthWithAspectRatio = cropperHeight * settings.aspectRatio;
|
|
521
328
|
cropperPosition.x1 = (sourceImageElement.offsetWidth - cropperWidthWithAspectRatio) / 2;
|
|
522
329
|
cropperPosition.x2 = cropperPosition.x1 + cropperWidthWithAspectRatio;
|
|
523
330
|
}
|
|
524
331
|
}
|
|
525
332
|
}
|
|
526
|
-
/**
|
|
527
|
-
* @param {?} event
|
|
528
|
-
* @param {?} moveStart
|
|
529
|
-
* @param {?} cropperPosition
|
|
530
|
-
* @return {?}
|
|
531
|
-
*/
|
|
532
333
|
move(event, moveStart, cropperPosition) {
|
|
533
|
-
/** @type {?} */
|
|
534
334
|
const diffX = this.getClientX(event) - moveStart.clientX;
|
|
535
|
-
/** @type {?} */
|
|
536
335
|
const diffY = this.getClientY(event) - moveStart.clientY;
|
|
537
336
|
cropperPosition.x1 = moveStart.x1 + diffX;
|
|
538
337
|
cropperPosition.y1 = moveStart.y1 + diffY;
|
|
539
338
|
cropperPosition.x2 = moveStart.x2 + diffX;
|
|
540
339
|
cropperPosition.y2 = moveStart.y2 + diffY;
|
|
541
340
|
}
|
|
542
|
-
/**
|
|
543
|
-
* @param {?} event
|
|
544
|
-
* @param {?} moveStart
|
|
545
|
-
* @param {?} cropperPosition
|
|
546
|
-
* @param {?} maxSize
|
|
547
|
-
* @param {?} settings
|
|
548
|
-
* @return {?}
|
|
549
|
-
*/
|
|
550
341
|
resize(event, moveStart, cropperPosition, maxSize, settings) {
|
|
551
|
-
/** @type {?} */
|
|
552
342
|
const moveX = this.getClientX(event) - moveStart.clientX;
|
|
553
|
-
/** @type {?} */
|
|
554
343
|
const moveY = this.getClientY(event) - moveStart.clientY;
|
|
555
344
|
switch (moveStart.position) {
|
|
556
345
|
case 'left':
|
|
@@ -582,11 +371,8 @@ class CropperPositionService {
|
|
|
582
371
|
cropperPosition.y2 = Math.max(Math.min(moveStart.y2 + moveY, cropperPosition.y1 + settings.cropperScaledMaxHeight), cropperPosition.y1 + settings.cropperScaledMinHeight);
|
|
583
372
|
break;
|
|
584
373
|
case 'center':
|
|
585
|
-
/** @type {?} */
|
|
586
374
|
const scale = event.scale;
|
|
587
|
-
/** @type {?} */
|
|
588
375
|
const newWidth = Math.min(Math.max(settings.cropperScaledMinWidth, (Math.abs(moveStart.x2 - moveStart.x1)) * scale), settings.cropperScaledMaxWidth);
|
|
589
|
-
/** @type {?} */
|
|
590
376
|
const newHeight = Math.min(Math.max(settings.cropperScaledMinHeight, (Math.abs(moveStart.y2 - moveStart.y1)) * scale), settings.cropperScaledMaxHeight);
|
|
591
377
|
cropperPosition.x1 = moveStart.clientX - newWidth / 2;
|
|
592
378
|
cropperPosition.x2 = moveStart.clientX + newWidth / 2;
|
|
@@ -614,17 +400,8 @@ class CropperPositionService {
|
|
|
614
400
|
this.checkAspectRatio(moveStart.position, cropperPosition, maxSize, settings);
|
|
615
401
|
}
|
|
616
402
|
}
|
|
617
|
-
/**
|
|
618
|
-
* @param {?} position
|
|
619
|
-
* @param {?} cropperPosition
|
|
620
|
-
* @param {?} maxSize
|
|
621
|
-
* @param {?} settings
|
|
622
|
-
* @return {?}
|
|
623
|
-
*/
|
|
624
403
|
checkAspectRatio(position, cropperPosition, maxSize, settings) {
|
|
625
|
-
/** @type {?} */
|
|
626
404
|
let overflowX = 0;
|
|
627
|
-
/** @type {?} */
|
|
628
405
|
let overflowY = 0;
|
|
629
406
|
switch (position) {
|
|
630
407
|
case 'top':
|
|
@@ -686,13 +463,9 @@ class CropperPositionService {
|
|
|
686
463
|
case 'center':
|
|
687
464
|
cropperPosition.x2 = cropperPosition.x1 + (cropperPosition.y2 - cropperPosition.y1) * settings.aspectRatio;
|
|
688
465
|
cropperPosition.y2 = cropperPosition.y1 + (cropperPosition.x2 - cropperPosition.x1) / settings.aspectRatio;
|
|
689
|
-
/** @type {?} */
|
|
690
466
|
const overflowX1 = Math.max(0 - cropperPosition.x1, 0);
|
|
691
|
-
/** @type {?} */
|
|
692
467
|
const overflowX2 = Math.max(cropperPosition.x2 - maxSize.width, 0);
|
|
693
|
-
/** @type {?} */
|
|
694
468
|
const overflowY1 = Math.max(cropperPosition.y2 - maxSize.height, 0);
|
|
695
|
-
/** @type {?} */
|
|
696
469
|
const overflowY2 = Math.max(0 - cropperPosition.y1, 0);
|
|
697
470
|
if (overflowX1 > 0 || overflowX2 > 0 || overflowY1 > 0 || overflowY2 > 0) {
|
|
698
471
|
cropperPosition.x1 += (overflowY1 * settings.aspectRatio) > overflowX1 ? (overflowY1 * settings.aspectRatio) : overflowX1;
|
|
@@ -703,70 +476,42 @@ class CropperPositionService {
|
|
|
703
476
|
break;
|
|
704
477
|
}
|
|
705
478
|
}
|
|
706
|
-
/**
|
|
707
|
-
* @param {?} event
|
|
708
|
-
* @return {?}
|
|
709
|
-
*/
|
|
710
479
|
getClientX(event) {
|
|
711
480
|
var _a;
|
|
712
481
|
return ((_a = event.touches) === null || _a === void 0 ? void 0 : _a[0].clientX) || event.clientX || 0;
|
|
713
482
|
}
|
|
714
|
-
/**
|
|
715
|
-
* @param {?} event
|
|
716
|
-
* @return {?}
|
|
717
|
-
*/
|
|
718
483
|
getClientY(event) {
|
|
719
484
|
var _a;
|
|
720
485
|
return ((_a = event.touches) === null || _a === void 0 ? void 0 : _a[0].clientY) || event.clientY || 0;
|
|
721
486
|
}
|
|
722
487
|
}
|
|
723
|
-
CropperPositionService
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
488
|
+
CropperPositionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: CropperPositionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
489
|
+
CropperPositionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: CropperPositionService, providedIn: 'root' });
|
|
490
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: CropperPositionService, decorators: [{
|
|
491
|
+
type: Injectable,
|
|
492
|
+
args: [{ providedIn: 'root' }]
|
|
493
|
+
}] });
|
|
727
494
|
|
|
728
|
-
/**
|
|
729
|
-
* @fileoverview added by tsickle
|
|
730
|
-
* Generated from: lib/utils/exif.utils.ts
|
|
731
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
732
|
-
*/
|
|
733
495
|
// Black 2x1 JPEG, with the following meta information set:
|
|
734
496
|
// - EXIF Orientation: 6 (Rotated 90° CCW)
|
|
735
497
|
// Source: https://github.com/blueimp/JavaScript-Load-Image
|
|
736
|
-
/** @type {?} */
|
|
737
498
|
const testAutoOrientationImageURL = 'data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAA' +
|
|
738
499
|
'AAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBA' +
|
|
739
500
|
'QEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE' +
|
|
740
501
|
'BAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAEAAgMBEQACEQEDEQH/x' +
|
|
741
502
|
'ABKAAEAAAAAAAAAAAAAAAAAAAALEAEAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAAAAAAA' +
|
|
742
503
|
'AAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwA/8H//2Q==';
|
|
743
|
-
/**
|
|
744
|
-
* @return {?}
|
|
745
|
-
*/
|
|
746
504
|
function supportsAutomaticRotation() {
|
|
747
|
-
return new Promise((
|
|
748
|
-
* @param {?} resolve
|
|
749
|
-
* @return {?}
|
|
750
|
-
*/
|
|
751
|
-
(resolve) => {
|
|
752
|
-
/** @type {?} */
|
|
505
|
+
return new Promise((resolve) => {
|
|
753
506
|
const img = new Image();
|
|
754
|
-
img.onload = (
|
|
755
|
-
* @return {?}
|
|
756
|
-
*/
|
|
757
|
-
() => {
|
|
507
|
+
img.onload = () => {
|
|
758
508
|
// Check if browser supports automatic image orientation:
|
|
759
|
-
/** @type {?} */
|
|
760
509
|
const supported = img.width === 1 && img.height === 2;
|
|
761
510
|
resolve(supported);
|
|
762
|
-
}
|
|
511
|
+
};
|
|
763
512
|
img.src = testAutoOrientationImageURL;
|
|
764
|
-
})
|
|
513
|
+
});
|
|
765
514
|
}
|
|
766
|
-
/**
|
|
767
|
-
* @param {?} exifRotationOrBase64Image
|
|
768
|
-
* @return {?}
|
|
769
|
-
*/
|
|
770
515
|
function getTransformationsFromExifData(exifRotationOrBase64Image) {
|
|
771
516
|
if (typeof exifRotationOrBase64Image === 'string') {
|
|
772
517
|
exifRotationOrBase64Image = getExifRotation(exifRotationOrBase64Image);
|
|
@@ -790,34 +535,24 @@ function getTransformationsFromExifData(exifRotationOrBase64Image) {
|
|
|
790
535
|
return { rotate: 0, flip: false };
|
|
791
536
|
}
|
|
792
537
|
}
|
|
793
|
-
/**
|
|
794
|
-
* @param {?} imageBase64
|
|
795
|
-
* @return {?}
|
|
796
|
-
*/
|
|
797
538
|
function getExifRotation(imageBase64) {
|
|
798
|
-
/** @type {?} */
|
|
799
539
|
const view = new DataView(base64ToArrayBuffer(imageBase64));
|
|
800
540
|
if (view.getUint16(0, false) !== 0xFFD8) {
|
|
801
541
|
return -2;
|
|
802
542
|
}
|
|
803
|
-
/** @type {?} */
|
|
804
543
|
const length = view.byteLength;
|
|
805
|
-
/** @type {?} */
|
|
806
544
|
let offset = 2;
|
|
807
545
|
while (offset < length) {
|
|
808
546
|
if (view.getUint16(offset + 2, false) <= 8)
|
|
809
547
|
return -1;
|
|
810
|
-
/** @type {?} */
|
|
811
548
|
const marker = view.getUint16(offset, false);
|
|
812
549
|
offset += 2;
|
|
813
550
|
if (marker == 0xFFE1) {
|
|
814
551
|
if (view.getUint32(offset += 2, false) !== 0x45786966) {
|
|
815
552
|
return -1;
|
|
816
553
|
}
|
|
817
|
-
/** @type {?} */
|
|
818
554
|
const little = view.getUint16(offset += 6, false) == 0x4949;
|
|
819
555
|
offset += view.getUint32(offset + 4, little);
|
|
820
|
-
/** @type {?} */
|
|
821
556
|
const tags = view.getUint16(offset, little);
|
|
822
557
|
offset += 2;
|
|
823
558
|
for (let i = 0; i < tags; i++) {
|
|
@@ -835,17 +570,10 @@ function getExifRotation(imageBase64) {
|
|
|
835
570
|
}
|
|
836
571
|
return -1;
|
|
837
572
|
}
|
|
838
|
-
/**
|
|
839
|
-
* @param {?} imageBase64
|
|
840
|
-
* @return {?}
|
|
841
|
-
*/
|
|
842
573
|
function base64ToArrayBuffer(imageBase64) {
|
|
843
574
|
imageBase64 = imageBase64.replace(/^data\:([^\;]+)\;base64,/gmi, '');
|
|
844
|
-
/** @type {?} */
|
|
845
575
|
const binaryString = atob(imageBase64);
|
|
846
|
-
/** @type {?} */
|
|
847
576
|
const len = binaryString.length;
|
|
848
|
-
/** @type {?} */
|
|
849
577
|
const bytes = new Uint8Array(len);
|
|
850
578
|
for (let i = 0; i < len; i++) {
|
|
851
579
|
bytes[i] = binaryString.charCodeAt(i);
|
|
@@ -853,152 +581,64 @@ function base64ToArrayBuffer(imageBase64) {
|
|
|
853
581
|
return bytes.buffer;
|
|
854
582
|
}
|
|
855
583
|
|
|
856
|
-
/**
|
|
857
|
-
* @fileoverview added by tsickle
|
|
858
|
-
* Generated from: lib/services/load-image.service.ts
|
|
859
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
860
|
-
*/
|
|
861
|
-
/**
|
|
862
|
-
* @record
|
|
863
|
-
*/
|
|
864
|
-
function LoadImageBase64() { }
|
|
865
|
-
if (false) {
|
|
866
|
-
/** @type {?} */
|
|
867
|
-
LoadImageBase64.prototype.originalImage;
|
|
868
|
-
/** @type {?} */
|
|
869
|
-
LoadImageBase64.prototype.originalBase64;
|
|
870
|
-
}
|
|
871
584
|
class LoadImageService {
|
|
872
585
|
constructor() {
|
|
873
586
|
this.autoRotateSupported = supportsAutomaticRotation();
|
|
874
587
|
}
|
|
875
|
-
/**
|
|
876
|
-
* @param {?} file
|
|
877
|
-
* @param {?} cropperSettings
|
|
878
|
-
* @return {?}
|
|
879
|
-
*/
|
|
880
588
|
loadImageFile(file, cropperSettings) {
|
|
881
|
-
return new Promise((
|
|
882
|
-
* @param {?} resolve
|
|
883
|
-
* @param {?} reject
|
|
884
|
-
* @return {?}
|
|
885
|
-
*/
|
|
886
|
-
(resolve, reject) => {
|
|
887
|
-
/** @type {?} */
|
|
589
|
+
return new Promise((resolve, reject) => {
|
|
888
590
|
const fileReader = new FileReader();
|
|
889
|
-
fileReader.onload = (
|
|
890
|
-
* @param {?} event
|
|
891
|
-
* @return {?}
|
|
892
|
-
*/
|
|
893
|
-
(event) => {
|
|
591
|
+
fileReader.onload = (event) => {
|
|
894
592
|
this.loadImage(event.target.result, file.type, cropperSettings)
|
|
895
593
|
.then(resolve)
|
|
896
594
|
.catch(reject);
|
|
897
|
-
}
|
|
595
|
+
};
|
|
898
596
|
fileReader.readAsDataURL(file);
|
|
899
|
-
})
|
|
597
|
+
});
|
|
900
598
|
}
|
|
901
|
-
/**
|
|
902
|
-
* @private
|
|
903
|
-
* @param {?} imageBase64
|
|
904
|
-
* @param {?} imageType
|
|
905
|
-
* @param {?} cropperSettings
|
|
906
|
-
* @return {?}
|
|
907
|
-
*/
|
|
908
599
|
loadImage(imageBase64, imageType, cropperSettings) {
|
|
909
600
|
if (!this.isValidImageType(imageType)) {
|
|
910
601
|
return Promise.reject(new Error('Invalid image type'));
|
|
911
602
|
}
|
|
912
603
|
return this.loadBase64Image(imageBase64, cropperSettings);
|
|
913
604
|
}
|
|
914
|
-
/**
|
|
915
|
-
* @private
|
|
916
|
-
* @param {?} type
|
|
917
|
-
* @return {?}
|
|
918
|
-
*/
|
|
919
605
|
isValidImageType(type) {
|
|
920
|
-
return /image\/(png|jpg|jpeg|bmp|gif|tiff|webp)/.test(type);
|
|
606
|
+
return /image\/(png|jpg|jpeg|bmp|gif|tiff|webp|x-icon|vnd.microsoft.icon)/.test(type);
|
|
921
607
|
}
|
|
922
|
-
/**
|
|
923
|
-
* @param {?} url
|
|
924
|
-
* @param {?} cropperSettings
|
|
925
|
-
* @return {?}
|
|
926
|
-
*/
|
|
927
608
|
loadImageFromURL(url, cropperSettings) {
|
|
928
|
-
return new Promise((
|
|
929
|
-
* @param {?} resolve
|
|
930
|
-
* @param {?} reject
|
|
931
|
-
* @return {?}
|
|
932
|
-
*/
|
|
933
|
-
(resolve, reject) => {
|
|
934
|
-
/** @type {?} */
|
|
609
|
+
return new Promise((resolve, reject) => {
|
|
935
610
|
const img = new Image();
|
|
936
|
-
img.onerror = (
|
|
937
|
-
|
|
938
|
-
*/
|
|
939
|
-
() => reject);
|
|
940
|
-
img.onload = (/**
|
|
941
|
-
* @return {?}
|
|
942
|
-
*/
|
|
943
|
-
() => {
|
|
944
|
-
/** @type {?} */
|
|
611
|
+
img.onerror = () => reject;
|
|
612
|
+
img.onload = () => {
|
|
945
613
|
const canvas = document.createElement('canvas');
|
|
946
|
-
/** @type {?} */
|
|
947
614
|
const context = canvas.getContext('2d');
|
|
948
615
|
canvas.width = img.width;
|
|
949
616
|
canvas.height = img.height;
|
|
950
|
-
context.drawImage(img, 0, 0);
|
|
617
|
+
context === null || context === void 0 ? void 0 : context.drawImage(img, 0, 0);
|
|
951
618
|
this.loadBase64Image(canvas.toDataURL(), cropperSettings).then(resolve);
|
|
952
|
-
}
|
|
619
|
+
};
|
|
953
620
|
img.crossOrigin = 'anonymous';
|
|
954
621
|
img.src = url;
|
|
955
|
-
})
|
|
622
|
+
});
|
|
956
623
|
}
|
|
957
|
-
/**
|
|
958
|
-
* @param {?} imageBase64
|
|
959
|
-
* @param {?} cropperSettings
|
|
960
|
-
* @return {?}
|
|
961
|
-
*/
|
|
962
624
|
loadBase64Image(imageBase64, cropperSettings) {
|
|
963
|
-
return new Promise((
|
|
964
|
-
* @param {?} resolve
|
|
965
|
-
* @param {?} reject
|
|
966
|
-
* @return {?}
|
|
967
|
-
*/
|
|
968
|
-
(resolve, reject) => {
|
|
969
|
-
/** @type {?} */
|
|
625
|
+
return new Promise((resolve, reject) => {
|
|
970
626
|
const originalImage = new Image();
|
|
971
|
-
originalImage.onload = (
|
|
972
|
-
* @return {?}
|
|
973
|
-
*/
|
|
974
|
-
() => resolve({
|
|
627
|
+
originalImage.onload = () => resolve({
|
|
975
628
|
originalImage,
|
|
976
629
|
originalBase64: imageBase64
|
|
977
|
-
})
|
|
630
|
+
});
|
|
978
631
|
originalImage.onerror = reject;
|
|
979
632
|
originalImage.src = imageBase64;
|
|
980
|
-
})
|
|
981
|
-
|
|
982
|
-
* @return {?}
|
|
983
|
-
*/
|
|
984
|
-
(res) => this.transformImageBase64(res, cropperSettings)));
|
|
985
|
-
}
|
|
986
|
-
/**
|
|
987
|
-
* @private
|
|
988
|
-
* @param {?} res
|
|
989
|
-
* @param {?} cropperSettings
|
|
990
|
-
* @return {?}
|
|
991
|
-
*/
|
|
633
|
+
}).then((res) => this.transformImageBase64(res, cropperSettings));
|
|
634
|
+
}
|
|
992
635
|
transformImageBase64(res, cropperSettings) {
|
|
993
636
|
return __awaiter(this, void 0, void 0, function* () {
|
|
994
|
-
/** @type {?} */
|
|
995
637
|
const autoRotate = yield this.autoRotateSupported;
|
|
996
|
-
/** @type {?} */
|
|
997
638
|
const exifTransform = yield getTransformationsFromExifData(autoRotate ? -1 : res.originalBase64);
|
|
998
639
|
if (!res.originalImage || !res.originalImage.complete) {
|
|
999
640
|
return Promise.reject(new Error('No image loaded'));
|
|
1000
641
|
}
|
|
1001
|
-
/** @type {?} */
|
|
1002
642
|
const loadedImage = {
|
|
1003
643
|
original: {
|
|
1004
644
|
base64: res.originalBase64,
|
|
@@ -1013,16 +653,9 @@ class LoadImageService {
|
|
|
1013
653
|
return this.transformLoadedImage(loadedImage, cropperSettings);
|
|
1014
654
|
});
|
|
1015
655
|
}
|
|
1016
|
-
/**
|
|
1017
|
-
* @param {?} loadedImage
|
|
1018
|
-
* @param {?} cropperSettings
|
|
1019
|
-
* @return {?}
|
|
1020
|
-
*/
|
|
1021
656
|
transformLoadedImage(loadedImage, cropperSettings) {
|
|
1022
657
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1023
|
-
/** @type {?} */
|
|
1024
658
|
const canvasRotation = cropperSettings.canvasRotation + loadedImage.exifTransform.rotate;
|
|
1025
|
-
/** @type {?} */
|
|
1026
659
|
const originalSize = {
|
|
1027
660
|
width: loadedImage.original.image.naturalWidth,
|
|
1028
661
|
height: loadedImage.original.image.naturalHeight
|
|
@@ -1042,20 +675,15 @@ class LoadImageService {
|
|
|
1042
675
|
exifTransform: loadedImage.exifTransform
|
|
1043
676
|
};
|
|
1044
677
|
}
|
|
1045
|
-
/** @type {?} */
|
|
1046
678
|
const transformedSize = this.getTransformedSize(originalSize, loadedImage.exifTransform, cropperSettings);
|
|
1047
|
-
/** @type {?} */
|
|
1048
679
|
const canvas = document.createElement('canvas');
|
|
1049
680
|
canvas.width = transformedSize.width;
|
|
1050
681
|
canvas.height = transformedSize.height;
|
|
1051
|
-
/** @type {?} */
|
|
1052
682
|
const ctx = canvas.getContext('2d');
|
|
1053
|
-
ctx.setTransform(loadedImage.exifTransform.flip ? -1 : 1, 0, 0, 1, canvas.width / 2, canvas.height / 2);
|
|
1054
|
-
ctx.rotate(Math.PI * (canvasRotation / 2));
|
|
1055
|
-
ctx.drawImage(loadedImage.original.image, -originalSize.width / 2, -originalSize.height / 2);
|
|
1056
|
-
/** @type {?} */
|
|
683
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.setTransform(loadedImage.exifTransform.flip ? -1 : 1, 0, 0, 1, canvas.width / 2, canvas.height / 2);
|
|
684
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.rotate(Math.PI * (canvasRotation / 2));
|
|
685
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(loadedImage.original.image, -originalSize.width / 2, -originalSize.height / 2);
|
|
1057
686
|
const transformedBase64 = canvas.toDataURL();
|
|
1058
|
-
/** @type {?} */
|
|
1059
687
|
const transformedImage = yield this.loadImageFromBase64(transformedBase64);
|
|
1060
688
|
return {
|
|
1061
689
|
original: {
|
|
@@ -1075,43 +703,19 @@ class LoadImageService {
|
|
|
1075
703
|
};
|
|
1076
704
|
});
|
|
1077
705
|
}
|
|
1078
|
-
/**
|
|
1079
|
-
* @private
|
|
1080
|
-
* @param {?} imageBase64
|
|
1081
|
-
* @return {?}
|
|
1082
|
-
*/
|
|
1083
706
|
loadImageFromBase64(imageBase64) {
|
|
1084
|
-
return new Promise(((
|
|
1085
|
-
* @param {?} resolve
|
|
1086
|
-
* @param {?} reject
|
|
1087
|
-
* @return {?}
|
|
1088
|
-
*/
|
|
1089
|
-
(resolve, reject) => {
|
|
1090
|
-
/** @type {?} */
|
|
707
|
+
return new Promise(((resolve, reject) => {
|
|
1091
708
|
const image = new Image();
|
|
1092
|
-
image.onload = (
|
|
1093
|
-
* @return {?}
|
|
1094
|
-
*/
|
|
1095
|
-
() => resolve(image));
|
|
709
|
+
image.onload = () => resolve(image);
|
|
1096
710
|
image.onerror = reject;
|
|
1097
711
|
image.src = imageBase64;
|
|
1098
|
-
}))
|
|
1099
|
-
}
|
|
1100
|
-
/**
|
|
1101
|
-
* @private
|
|
1102
|
-
* @param {?} originalSize
|
|
1103
|
-
* @param {?} exifTransform
|
|
1104
|
-
* @param {?} cropperSettings
|
|
1105
|
-
* @return {?}
|
|
1106
|
-
*/
|
|
712
|
+
}));
|
|
713
|
+
}
|
|
1107
714
|
getTransformedSize(originalSize, exifTransform, cropperSettings) {
|
|
1108
|
-
/** @type {?} */
|
|
1109
715
|
const canvasRotation = cropperSettings.canvasRotation + exifTransform.rotate;
|
|
1110
716
|
if (cropperSettings.containWithinAspectRatio) {
|
|
1111
717
|
if (canvasRotation % 2) {
|
|
1112
|
-
/** @type {?} */
|
|
1113
718
|
const minWidthToContain = originalSize.width * cropperSettings.aspectRatio;
|
|
1114
|
-
/** @type {?} */
|
|
1115
719
|
const minHeightToContain = originalSize.height / cropperSettings.aspectRatio;
|
|
1116
720
|
return {
|
|
1117
721
|
width: Math.max(originalSize.height, minWidthToContain),
|
|
@@ -1119,9 +723,7 @@ class LoadImageService {
|
|
|
1119
723
|
};
|
|
1120
724
|
}
|
|
1121
725
|
else {
|
|
1122
|
-
/** @type {?} */
|
|
1123
726
|
const minWidthToContain = originalSize.height * cropperSettings.aspectRatio;
|
|
1124
|
-
/** @type {?} */
|
|
1125
727
|
const minHeightToContain = originalSize.width / cropperSettings.aspectRatio;
|
|
1126
728
|
return {
|
|
1127
729
|
width: Math.max(originalSize.width, minWidthToContain),
|
|
@@ -1141,89 +743,14 @@ class LoadImageService {
|
|
|
1141
743
|
};
|
|
1142
744
|
}
|
|
1143
745
|
}
|
|
1144
|
-
LoadImageService
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
* @type {?}
|
|
1151
|
-
* @private
|
|
1152
|
-
*/
|
|
1153
|
-
LoadImageService.prototype.autoRotateSupported;
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
/**
|
|
1157
|
-
* @fileoverview added by tsickle
|
|
1158
|
-
* Generated from: lib/utils/keyboard.utils.ts
|
|
1159
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1160
|
-
*/
|
|
1161
|
-
/**
|
|
1162
|
-
* @param {?} key
|
|
1163
|
-
* @return {?}
|
|
1164
|
-
*/
|
|
1165
|
-
function getPositionForKey(key) {
|
|
1166
|
-
switch (key) {
|
|
1167
|
-
case 'ArrowUp':
|
|
1168
|
-
return 'top';
|
|
1169
|
-
case 'ArrowRight':
|
|
1170
|
-
return 'right';
|
|
1171
|
-
case 'ArrowDown':
|
|
1172
|
-
return 'bottom';
|
|
1173
|
-
case 'ArrowLeft':
|
|
1174
|
-
default:
|
|
1175
|
-
return 'left';
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
/**
|
|
1179
|
-
* @param {?} key
|
|
1180
|
-
* @return {?}
|
|
1181
|
-
*/
|
|
1182
|
-
function getInvertedPositionForKey(key) {
|
|
1183
|
-
switch (key) {
|
|
1184
|
-
case 'ArrowUp':
|
|
1185
|
-
return 'bottom';
|
|
1186
|
-
case 'ArrowRight':
|
|
1187
|
-
return 'left';
|
|
1188
|
-
case 'ArrowDown':
|
|
1189
|
-
return 'top';
|
|
1190
|
-
case 'ArrowLeft':
|
|
1191
|
-
default:
|
|
1192
|
-
return 'right';
|
|
1193
|
-
}
|
|
1194
|
-
}
|
|
1195
|
-
/**
|
|
1196
|
-
* @param {?} key
|
|
1197
|
-
* @param {?} stepSize
|
|
1198
|
-
* @return {?}
|
|
1199
|
-
*/
|
|
1200
|
-
function getEventForKey(key, stepSize) {
|
|
1201
|
-
switch (key) {
|
|
1202
|
-
case 'ArrowUp':
|
|
1203
|
-
return { clientX: 0, clientY: stepSize * -1 };
|
|
1204
|
-
case 'ArrowRight':
|
|
1205
|
-
return { clientX: stepSize, clientY: 0 };
|
|
1206
|
-
case 'ArrowDown':
|
|
1207
|
-
return { clientX: 0, clientY: stepSize };
|
|
1208
|
-
case 'ArrowLeft':
|
|
1209
|
-
default:
|
|
1210
|
-
return { clientX: stepSize * -1, clientY: 0 };
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
746
|
+
LoadImageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: LoadImageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
747
|
+
LoadImageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: LoadImageService, providedIn: 'root' });
|
|
748
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: LoadImageService, decorators: [{
|
|
749
|
+
type: Injectable,
|
|
750
|
+
args: [{ providedIn: 'root' }]
|
|
751
|
+
}] });
|
|
1213
752
|
|
|
1214
|
-
/**
|
|
1215
|
-
* @fileoverview added by tsickle
|
|
1216
|
-
* Generated from: lib/component/image-cropper.component.ts
|
|
1217
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1218
|
-
*/
|
|
1219
753
|
class ImageCropperComponent {
|
|
1220
|
-
/**
|
|
1221
|
-
* @param {?} cropService
|
|
1222
|
-
* @param {?} cropperPositionService
|
|
1223
|
-
* @param {?} loadImageService
|
|
1224
|
-
* @param {?} sanitizer
|
|
1225
|
-
* @param {?} cd
|
|
1226
|
-
*/
|
|
1227
754
|
constructor(cropService, cropperPositionService, loadImageService, sanitizer, cd) {
|
|
1228
755
|
this.cropService = cropService;
|
|
1229
756
|
this.cropperPositionService = cropperPositionService;
|
|
@@ -1234,6 +761,10 @@ class ImageCropperComponent {
|
|
|
1234
761
|
this.settings = new CropperSettings();
|
|
1235
762
|
this.setImageMaxSizeRetries = 0;
|
|
1236
763
|
this.marginLeft = '0px';
|
|
764
|
+
this.maxSize = {
|
|
765
|
+
width: 0,
|
|
766
|
+
height: 0
|
|
767
|
+
};
|
|
1237
768
|
this.moveTypes = MoveTypes;
|
|
1238
769
|
this.imageVisible = false;
|
|
1239
770
|
this.format = this.settings.format;
|
|
@@ -1272,52 +803,35 @@ class ImageCropperComponent {
|
|
|
1272
803
|
this.loadImageFailed = new EventEmitter();
|
|
1273
804
|
this.reset();
|
|
1274
805
|
}
|
|
1275
|
-
/**
|
|
1276
|
-
* @param {?} changes
|
|
1277
|
-
* @return {?}
|
|
1278
|
-
*/
|
|
1279
806
|
ngOnChanges(changes) {
|
|
1280
807
|
var _a;
|
|
1281
808
|
this.onChangesUpdateSettings(changes);
|
|
1282
809
|
this.onChangesInputImage(changes);
|
|
1283
|
-
if (((_a = this.loadedImage) === null || _a === void 0 ? void 0 : _a.original.image.complete) && (changes
|
|
810
|
+
if (((_a = this.loadedImage) === null || _a === void 0 ? void 0 : _a.original.image.complete) && (changes['containWithinAspectRatio'] || changes['canvasRotation'])) {
|
|
1284
811
|
this.loadImageService
|
|
1285
812
|
.transformLoadedImage(this.loadedImage, this.settings)
|
|
1286
|
-
.then((
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
(res) => this.setLoadedImage(res)))
|
|
1291
|
-
.catch((/**
|
|
1292
|
-
* @param {?} err
|
|
1293
|
-
* @return {?}
|
|
1294
|
-
*/
|
|
1295
|
-
(err) => this.loadImageError(err)));
|
|
1296
|
-
}
|
|
1297
|
-
if (changes.cropper || changes.maintainAspectRatio || changes.aspectRatio) {
|
|
813
|
+
.then((res) => this.setLoadedImage(res))
|
|
814
|
+
.catch((err) => this.loadImageError(err));
|
|
815
|
+
}
|
|
816
|
+
if (changes['cropper'] || changes['maintainAspectRatio'] || changes['aspectRatio']) {
|
|
1298
817
|
this.setMaxSize();
|
|
1299
818
|
this.setCropperScaledMinSize();
|
|
1300
819
|
this.setCropperScaledMaxSize();
|
|
1301
|
-
if (this.maintainAspectRatio && (changes
|
|
820
|
+
if (this.maintainAspectRatio && (changes['maintainAspectRatio'] || changes['aspectRatio'])) {
|
|
1302
821
|
this.resetCropperPosition();
|
|
1303
822
|
}
|
|
1304
|
-
else if (changes
|
|
823
|
+
else if (changes['cropper']) {
|
|
1305
824
|
this.checkCropperPosition(false);
|
|
1306
825
|
this.doAutoCrop();
|
|
1307
826
|
}
|
|
1308
827
|
this.cd.markForCheck();
|
|
1309
828
|
}
|
|
1310
|
-
if (changes
|
|
829
|
+
if (changes['transform']) {
|
|
1311
830
|
this.transform = this.transform || {};
|
|
1312
831
|
this.setCssTransform();
|
|
1313
832
|
this.doAutoCrop();
|
|
1314
833
|
}
|
|
1315
834
|
}
|
|
1316
|
-
/**
|
|
1317
|
-
* @private
|
|
1318
|
-
* @param {?} changes
|
|
1319
|
-
* @return {?}
|
|
1320
|
-
*/
|
|
1321
835
|
onChangesUpdateSettings(changes) {
|
|
1322
836
|
this.settings.setOptionsFromChanges(changes);
|
|
1323
837
|
if (this.settings.cropperStaticHeight && this.settings.cropperStaticWidth) {
|
|
@@ -1331,59 +845,39 @@ class ImageCropperComponent {
|
|
|
1331
845
|
});
|
|
1332
846
|
}
|
|
1333
847
|
}
|
|
1334
|
-
/**
|
|
1335
|
-
* @private
|
|
1336
|
-
* @param {?} changes
|
|
1337
|
-
* @return {?}
|
|
1338
|
-
*/
|
|
1339
848
|
onChangesInputImage(changes) {
|
|
1340
|
-
if (changes
|
|
849
|
+
if (changes['imageChangedEvent'] || changes['imageURL'] || changes['imageBase64'] || changes['imageFile']) {
|
|
1341
850
|
this.reset();
|
|
1342
851
|
}
|
|
1343
|
-
if (changes
|
|
852
|
+
if (changes['imageChangedEvent'] && this.isValidImageChangedEvent()) {
|
|
1344
853
|
this.loadImageFile(this.imageChangedEvent.target.files[0]);
|
|
1345
854
|
}
|
|
1346
|
-
if (changes
|
|
855
|
+
if (changes['imageURL'] && this.imageURL) {
|
|
1347
856
|
this.loadImageFromURL(this.imageURL);
|
|
1348
857
|
}
|
|
1349
|
-
if (changes
|
|
858
|
+
if (changes['imageBase64'] && this.imageBase64) {
|
|
1350
859
|
this.loadBase64Image(this.imageBase64);
|
|
1351
860
|
}
|
|
1352
|
-
if (changes
|
|
861
|
+
if (changes['imageFile'] && this.imageFile) {
|
|
1353
862
|
this.loadImageFile(this.imageFile);
|
|
1354
863
|
}
|
|
1355
864
|
}
|
|
1356
|
-
/**
|
|
1357
|
-
* @private
|
|
1358
|
-
* @return {?}
|
|
1359
|
-
*/
|
|
1360
865
|
isValidImageChangedEvent() {
|
|
1361
866
|
var _a, _b, _c;
|
|
1362
867
|
return ((_c = (_b = (_a = this.imageChangedEvent) === null || _a === void 0 ? void 0 : _a.target) === null || _b === void 0 ? void 0 : _b.files) === null || _c === void 0 ? void 0 : _c.length) > 0;
|
|
1363
868
|
}
|
|
1364
|
-
/**
|
|
1365
|
-
* @private
|
|
1366
|
-
* @return {?}
|
|
1367
|
-
*/
|
|
1368
869
|
setCssTransform() {
|
|
1369
870
|
this.safeTransformStyle = this.sanitizer.bypassSecurityTrustStyle('scaleX(' + (this.transform.scale || 1) * (this.transform.flipH ? -1 : 1) + ')' +
|
|
1370
871
|
'scaleY(' + (this.transform.scale || 1) * (this.transform.flipV ? -1 : 1) + ')' +
|
|
1371
872
|
'rotate(' + (this.transform.rotate || 0) + 'deg)');
|
|
1372
873
|
}
|
|
1373
|
-
/**
|
|
1374
|
-
* @return {?}
|
|
1375
|
-
*/
|
|
1376
874
|
ngOnInit() {
|
|
1377
875
|
this.settings.stepSize = this.initialStepSize;
|
|
1378
876
|
this.activatePinchGesture();
|
|
1379
877
|
}
|
|
1380
|
-
/**
|
|
1381
|
-
* @private
|
|
1382
|
-
* @return {?}
|
|
1383
|
-
*/
|
|
1384
878
|
reset() {
|
|
1385
879
|
this.imageVisible = false;
|
|
1386
|
-
this.loadedImage =
|
|
880
|
+
this.loadedImage = undefined;
|
|
1387
881
|
this.safeImgDataUrl = 'data:image/png;base64,iVBORw0KGg'
|
|
1388
882
|
+ 'oAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAU'
|
|
1389
883
|
+ 'AAarVyFEAAAAASUVORK5CYII=';
|
|
@@ -1407,99 +901,40 @@ class ImageCropperComponent {
|
|
|
1407
901
|
this.cropper.x2 = 10000;
|
|
1408
902
|
this.cropper.y2 = 10000;
|
|
1409
903
|
}
|
|
1410
|
-
/**
|
|
1411
|
-
* @private
|
|
1412
|
-
* @param {?} file
|
|
1413
|
-
* @return {?}
|
|
1414
|
-
*/
|
|
1415
904
|
loadImageFile(file) {
|
|
1416
905
|
this.loadImageService
|
|
1417
906
|
.loadImageFile(file, this.settings)
|
|
1418
|
-
.then((
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
*/
|
|
1422
|
-
(res) => this.setLoadedImage(res)))
|
|
1423
|
-
.catch((/**
|
|
1424
|
-
* @param {?} err
|
|
1425
|
-
* @return {?}
|
|
1426
|
-
*/
|
|
1427
|
-
(err) => this.loadImageError(err)));
|
|
1428
|
-
}
|
|
1429
|
-
/**
|
|
1430
|
-
* @private
|
|
1431
|
-
* @param {?} imageBase64
|
|
1432
|
-
* @return {?}
|
|
1433
|
-
*/
|
|
907
|
+
.then((res) => this.setLoadedImage(res))
|
|
908
|
+
.catch((err) => this.loadImageError(err));
|
|
909
|
+
}
|
|
1434
910
|
loadBase64Image(imageBase64) {
|
|
1435
911
|
this.loadImageService
|
|
1436
912
|
.loadBase64Image(imageBase64, this.settings)
|
|
1437
|
-
.then((
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
*/
|
|
1441
|
-
(res) => this.setLoadedImage(res)))
|
|
1442
|
-
.catch((/**
|
|
1443
|
-
* @param {?} err
|
|
1444
|
-
* @return {?}
|
|
1445
|
-
*/
|
|
1446
|
-
(err) => this.loadImageError(err)));
|
|
1447
|
-
}
|
|
1448
|
-
/**
|
|
1449
|
-
* @private
|
|
1450
|
-
* @param {?} url
|
|
1451
|
-
* @return {?}
|
|
1452
|
-
*/
|
|
913
|
+
.then((res) => this.setLoadedImage(res))
|
|
914
|
+
.catch((err) => this.loadImageError(err));
|
|
915
|
+
}
|
|
1453
916
|
loadImageFromURL(url) {
|
|
1454
917
|
this.loadImageService
|
|
1455
918
|
.loadImageFromURL(url, this.settings)
|
|
1456
|
-
.then((
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
*/
|
|
1460
|
-
(res) => this.setLoadedImage(res)))
|
|
1461
|
-
.catch((/**
|
|
1462
|
-
* @param {?} err
|
|
1463
|
-
* @return {?}
|
|
1464
|
-
*/
|
|
1465
|
-
(err) => this.loadImageError(err)));
|
|
1466
|
-
}
|
|
1467
|
-
/**
|
|
1468
|
-
* @private
|
|
1469
|
-
* @param {?} loadedImage
|
|
1470
|
-
* @return {?}
|
|
1471
|
-
*/
|
|
919
|
+
.then((res) => this.setLoadedImage(res))
|
|
920
|
+
.catch((err) => this.loadImageError(err));
|
|
921
|
+
}
|
|
1472
922
|
setLoadedImage(loadedImage) {
|
|
1473
923
|
this.loadedImage = loadedImage;
|
|
1474
924
|
this.safeImgDataUrl = this.sanitizer.bypassSecurityTrustResourceUrl(loadedImage.transformed.base64);
|
|
1475
925
|
this.cd.markForCheck();
|
|
1476
926
|
}
|
|
1477
|
-
/**
|
|
1478
|
-
* @private
|
|
1479
|
-
* @param {?} error
|
|
1480
|
-
* @return {?}
|
|
1481
|
-
*/
|
|
1482
927
|
loadImageError(error) {
|
|
1483
928
|
console.error(error);
|
|
1484
929
|
this.loadImageFailed.emit();
|
|
1485
930
|
}
|
|
1486
|
-
/**
|
|
1487
|
-
* @return {?}
|
|
1488
|
-
*/
|
|
1489
931
|
imageLoadedInView() {
|
|
1490
932
|
if (this.loadedImage != null) {
|
|
1491
933
|
this.imageLoaded.emit(this.loadedImage);
|
|
1492
934
|
this.setImageMaxSizeRetries = 0;
|
|
1493
|
-
setTimeout((
|
|
1494
|
-
* @return {?}
|
|
1495
|
-
*/
|
|
1496
|
-
() => this.checkImageMaxSizeRecursively()));
|
|
935
|
+
setTimeout(() => this.checkImageMaxSizeRecursively());
|
|
1497
936
|
}
|
|
1498
937
|
}
|
|
1499
|
-
/**
|
|
1500
|
-
* @private
|
|
1501
|
-
* @return {?}
|
|
1502
|
-
*/
|
|
1503
938
|
checkImageMaxSizeRecursively() {
|
|
1504
939
|
if (this.setImageMaxSizeRetries > 40) {
|
|
1505
940
|
this.loadImageFailed.emit();
|
|
@@ -1514,23 +949,13 @@ class ImageCropperComponent {
|
|
|
1514
949
|
}
|
|
1515
950
|
else {
|
|
1516
951
|
this.setImageMaxSizeRetries++;
|
|
1517
|
-
setTimeout((
|
|
1518
|
-
* @return {?}
|
|
1519
|
-
*/
|
|
1520
|
-
() => this.checkImageMaxSizeRecursively()), 50);
|
|
952
|
+
setTimeout(() => this.checkImageMaxSizeRecursively(), 50);
|
|
1521
953
|
}
|
|
1522
954
|
}
|
|
1523
|
-
/**
|
|
1524
|
-
* @private
|
|
1525
|
-
* @return {?}
|
|
1526
|
-
*/
|
|
1527
955
|
sourceImageLoaded() {
|
|
1528
956
|
var _a, _b;
|
|
1529
957
|
return ((_b = (_a = this.sourceImage) === null || _a === void 0 ? void 0 : _a.nativeElement) === null || _b === void 0 ? void 0 : _b.offsetWidth) > 0;
|
|
1530
958
|
}
|
|
1531
|
-
/**
|
|
1532
|
-
* @return {?}
|
|
1533
|
-
*/
|
|
1534
959
|
onResize() {
|
|
1535
960
|
if (!this.loadedImage) {
|
|
1536
961
|
return;
|
|
@@ -1540,13 +965,8 @@ class ImageCropperComponent {
|
|
|
1540
965
|
this.setCropperScaledMinSize();
|
|
1541
966
|
this.setCropperScaledMaxSize();
|
|
1542
967
|
}
|
|
1543
|
-
/**
|
|
1544
|
-
* @private
|
|
1545
|
-
* @return {?}
|
|
1546
|
-
*/
|
|
1547
968
|
activatePinchGesture() {
|
|
1548
969
|
if (this.Hammer) {
|
|
1549
|
-
/** @type {?} */
|
|
1550
970
|
const hammer = new this.Hammer(this.wrapper.nativeElement);
|
|
1551
971
|
hammer.get('pinch').set({ enable: true });
|
|
1552
972
|
hammer.on('pinchmove', this.onPinch.bind(this));
|
|
@@ -1557,12 +977,7 @@ class ImageCropperComponent {
|
|
|
1557
977
|
console.warn('[NgxImageCropper] Could not find HammerJS - Pinch Gesture won\'t work');
|
|
1558
978
|
}
|
|
1559
979
|
}
|
|
1560
|
-
/**
|
|
1561
|
-
* @private
|
|
1562
|
-
* @return {?}
|
|
1563
|
-
*/
|
|
1564
980
|
resizeCropperPosition() {
|
|
1565
|
-
/** @type {?} */
|
|
1566
981
|
const sourceImageElement = this.sourceImage.nativeElement;
|
|
1567
982
|
if (this.maxSize.width !== sourceImageElement.offsetWidth || this.maxSize.height !== sourceImageElement.offsetHeight) {
|
|
1568
983
|
this.cropper.x1 = this.cropper.x1 * sourceImageElement.offsetWidth / this.maxSize.width;
|
|
@@ -1571,50 +986,28 @@ class ImageCropperComponent {
|
|
|
1571
986
|
this.cropper.y2 = this.cropper.y2 * sourceImageElement.offsetHeight / this.maxSize.height;
|
|
1572
987
|
}
|
|
1573
988
|
}
|
|
1574
|
-
/**
|
|
1575
|
-
* @return {?}
|
|
1576
|
-
*/
|
|
1577
989
|
resetCropperPosition() {
|
|
1578
990
|
this.cropperPositionService.resetCropperPosition(this.sourceImage, this.cropper, this.settings);
|
|
1579
991
|
this.doAutoCrop();
|
|
1580
992
|
this.imageVisible = true;
|
|
1581
993
|
}
|
|
1582
|
-
/**
|
|
1583
|
-
* @param {?} event
|
|
1584
|
-
* @return {?}
|
|
1585
|
-
*/
|
|
1586
994
|
keyboardAccess(event) {
|
|
1587
995
|
this.changeKeyboardStepSize(event);
|
|
1588
996
|
this.keyboardMoveCropper(event);
|
|
1589
997
|
}
|
|
1590
|
-
/**
|
|
1591
|
-
* @private
|
|
1592
|
-
* @param {?} event
|
|
1593
|
-
* @return {?}
|
|
1594
|
-
*/
|
|
1595
998
|
changeKeyboardStepSize(event) {
|
|
1596
|
-
/** @type {?} */
|
|
1597
999
|
const key = +event.key;
|
|
1598
1000
|
if (key >= 1 && key <= 9) {
|
|
1599
1001
|
this.settings.stepSize = key;
|
|
1600
1002
|
}
|
|
1601
1003
|
}
|
|
1602
|
-
/**
|
|
1603
|
-
* @private
|
|
1604
|
-
* @param {?} event
|
|
1605
|
-
* @return {?}
|
|
1606
|
-
*/
|
|
1607
1004
|
keyboardMoveCropper(event) {
|
|
1608
|
-
/** @type {?} */
|
|
1609
1005
|
const keyboardWhiteList = ['ArrowUp', 'ArrowDown', 'ArrowRight', 'ArrowLeft'];
|
|
1610
1006
|
if (!(keyboardWhiteList.includes(event.key))) {
|
|
1611
1007
|
return;
|
|
1612
1008
|
}
|
|
1613
|
-
/** @type {?} */
|
|
1614
1009
|
const moveType = event.shiftKey ? MoveTypes.Resize : MoveTypes.Move;
|
|
1615
|
-
/** @type {?} */
|
|
1616
1010
|
const position = event.altKey ? getInvertedPositionForKey(event.key) : getPositionForKey(event.key);
|
|
1617
|
-
/** @type {?} */
|
|
1618
1011
|
const moveEvent = getEventForKey(event.key, this.settings.stepSize);
|
|
1619
1012
|
event.preventDefault();
|
|
1620
1013
|
event.stopPropagation();
|
|
@@ -1622,12 +1015,6 @@ class ImageCropperComponent {
|
|
|
1622
1015
|
this.moveImg(moveEvent);
|
|
1623
1016
|
this.moveStop();
|
|
1624
1017
|
}
|
|
1625
|
-
/**
|
|
1626
|
-
* @param {?} event
|
|
1627
|
-
* @param {?} moveType
|
|
1628
|
-
* @param {?=} position
|
|
1629
|
-
* @return {?}
|
|
1630
|
-
*/
|
|
1631
1018
|
startMove(event, moveType, position = null) {
|
|
1632
1019
|
var _a, _b;
|
|
1633
1020
|
if (((_a = this.moveStart) === null || _a === void 0 ? void 0 : _a.active) && ((_b = this.moveStart) === null || _b === void 0 ? void 0 : _b.type) === MoveTypes.Pinch) {
|
|
@@ -1638,10 +1025,6 @@ class ImageCropperComponent {
|
|
|
1638
1025
|
}
|
|
1639
1026
|
this.moveStart = Object.assign({ active: true, type: moveType, position, clientX: this.cropperPositionService.getClientX(event), clientY: this.cropperPositionService.getClientY(event) }, this.cropper);
|
|
1640
1027
|
}
|
|
1641
|
-
/**
|
|
1642
|
-
* @param {?} event
|
|
1643
|
-
* @return {?}
|
|
1644
|
-
*/
|
|
1645
1028
|
startPinch(event) {
|
|
1646
1029
|
if (!this.safeImgDataUrl) {
|
|
1647
1030
|
return;
|
|
@@ -1651,10 +1034,6 @@ class ImageCropperComponent {
|
|
|
1651
1034
|
}
|
|
1652
1035
|
this.moveStart = Object.assign({ active: true, type: MoveTypes.Pinch, position: 'center', clientX: this.cropper.x1 + (this.cropper.x2 - this.cropper.x1) / 2, clientY: this.cropper.y1 + (this.cropper.y2 - this.cropper.y1) / 2 }, this.cropper);
|
|
1653
1036
|
}
|
|
1654
|
-
/**
|
|
1655
|
-
* @param {?} event
|
|
1656
|
-
* @return {?}
|
|
1657
|
-
*/
|
|
1658
1037
|
moveImg(event) {
|
|
1659
1038
|
if (this.moveStart.active) {
|
|
1660
1039
|
if (event.stopPropagation) {
|
|
@@ -1676,10 +1055,6 @@ class ImageCropperComponent {
|
|
|
1676
1055
|
this.cd.detectChanges();
|
|
1677
1056
|
}
|
|
1678
1057
|
}
|
|
1679
|
-
/**
|
|
1680
|
-
* @param {?} event
|
|
1681
|
-
* @return {?}
|
|
1682
|
-
*/
|
|
1683
1058
|
onPinch(event) {
|
|
1684
1059
|
if (this.moveStart.active) {
|
|
1685
1060
|
if (event.stopPropagation) {
|
|
@@ -1695,23 +1070,14 @@ class ImageCropperComponent {
|
|
|
1695
1070
|
this.cd.detectChanges();
|
|
1696
1071
|
}
|
|
1697
1072
|
}
|
|
1698
|
-
/**
|
|
1699
|
-
* @private
|
|
1700
|
-
* @return {?}
|
|
1701
|
-
*/
|
|
1702
1073
|
setMaxSize() {
|
|
1703
1074
|
if (this.sourceImage) {
|
|
1704
|
-
/** @type {?} */
|
|
1705
1075
|
const sourceImageElement = this.sourceImage.nativeElement;
|
|
1706
1076
|
this.maxSize.width = sourceImageElement.offsetWidth;
|
|
1707
1077
|
this.maxSize.height = sourceImageElement.offsetHeight;
|
|
1708
1078
|
this.marginLeft = this.sanitizer.bypassSecurityTrustStyle('calc(50% - ' + this.maxSize.width / 2 + 'px)');
|
|
1709
1079
|
}
|
|
1710
1080
|
}
|
|
1711
|
-
/**
|
|
1712
|
-
* @private
|
|
1713
|
-
* @return {?}
|
|
1714
|
-
*/
|
|
1715
1081
|
setCropperScaledMinSize() {
|
|
1716
1082
|
var _a, _b;
|
|
1717
1083
|
if ((_b = (_a = this.loadedImage) === null || _a === void 0 ? void 0 : _a.transformed) === null || _b === void 0 ? void 0 : _b.image) {
|
|
@@ -1723,19 +1089,11 @@ class ImageCropperComponent {
|
|
|
1723
1089
|
this.settings.cropperScaledMinHeight = 20;
|
|
1724
1090
|
}
|
|
1725
1091
|
}
|
|
1726
|
-
/**
|
|
1727
|
-
* @private
|
|
1728
|
-
* @return {?}
|
|
1729
|
-
*/
|
|
1730
1092
|
setCropperScaledMinWidth() {
|
|
1731
1093
|
this.settings.cropperScaledMinWidth = this.cropperMinWidth > 0
|
|
1732
1094
|
? Math.max(20, this.cropperMinWidth / this.loadedImage.transformed.image.width * this.maxSize.width)
|
|
1733
1095
|
: 20;
|
|
1734
1096
|
}
|
|
1735
|
-
/**
|
|
1736
|
-
* @private
|
|
1737
|
-
* @return {?}
|
|
1738
|
-
*/
|
|
1739
1097
|
setCropperScaledMinHeight() {
|
|
1740
1098
|
if (this.maintainAspectRatio) {
|
|
1741
1099
|
this.settings.cropperScaledMinHeight = Math.max(20, this.settings.cropperScaledMinWidth / this.aspectRatio);
|
|
@@ -1747,14 +1105,9 @@ class ImageCropperComponent {
|
|
|
1747
1105
|
this.settings.cropperScaledMinHeight = 20;
|
|
1748
1106
|
}
|
|
1749
1107
|
}
|
|
1750
|
-
/**
|
|
1751
|
-
* @private
|
|
1752
|
-
* @return {?}
|
|
1753
|
-
*/
|
|
1754
1108
|
setCropperScaledMaxSize() {
|
|
1755
1109
|
var _a, _b;
|
|
1756
1110
|
if ((_b = (_a = this.loadedImage) === null || _a === void 0 ? void 0 : _a.transformed) === null || _b === void 0 ? void 0 : _b.image) {
|
|
1757
|
-
/** @type {?} */
|
|
1758
1111
|
const ratio = this.loadedImage.transformed.size.width / this.maxSize.width;
|
|
1759
1112
|
this.settings.cropperScaledMaxWidth = this.cropperMaxWidth > 20 ? this.cropperMaxWidth / ratio : this.maxSize.width;
|
|
1760
1113
|
this.settings.cropperScaledMaxHeight = this.cropperMaxHeight > 20 ? this.cropperMaxHeight / ratio : this.maxSize.height;
|
|
@@ -1772,11 +1125,6 @@ class ImageCropperComponent {
|
|
|
1772
1125
|
this.settings.cropperScaledMaxHeight = this.maxSize.height;
|
|
1773
1126
|
}
|
|
1774
1127
|
}
|
|
1775
|
-
/**
|
|
1776
|
-
* @private
|
|
1777
|
-
* @param {?=} maintainSize
|
|
1778
|
-
* @return {?}
|
|
1779
|
-
*/
|
|
1780
1128
|
checkCropperPosition(maintainSize = false) {
|
|
1781
1129
|
if (this.cropper.x1 < 0) {
|
|
1782
1130
|
this.cropper.x2 -= maintainSize ? this.cropper.x1 : 0;
|
|
@@ -1795,41 +1143,27 @@ class ImageCropperComponent {
|
|
|
1795
1143
|
this.cropper.y2 = this.maxSize.height;
|
|
1796
1144
|
}
|
|
1797
1145
|
}
|
|
1798
|
-
/**
|
|
1799
|
-
* @return {?}
|
|
1800
|
-
*/
|
|
1801
1146
|
moveStop() {
|
|
1802
1147
|
if (this.moveStart.active) {
|
|
1803
1148
|
this.moveStart.active = false;
|
|
1804
1149
|
this.doAutoCrop();
|
|
1805
1150
|
}
|
|
1806
1151
|
}
|
|
1807
|
-
/**
|
|
1808
|
-
* @return {?}
|
|
1809
|
-
*/
|
|
1810
1152
|
pinchStop() {
|
|
1811
1153
|
if (this.moveStart.active) {
|
|
1812
1154
|
this.moveStart.active = false;
|
|
1813
1155
|
this.doAutoCrop();
|
|
1814
1156
|
}
|
|
1815
1157
|
}
|
|
1816
|
-
/**
|
|
1817
|
-
* @private
|
|
1818
|
-
* @return {?}
|
|
1819
|
-
*/
|
|
1820
1158
|
doAutoCrop() {
|
|
1821
1159
|
if (this.autoCrop) {
|
|
1822
1160
|
this.crop();
|
|
1823
1161
|
}
|
|
1824
1162
|
}
|
|
1825
|
-
/**
|
|
1826
|
-
* @return {?}
|
|
1827
|
-
*/
|
|
1828
1163
|
crop() {
|
|
1829
1164
|
var _a, _b;
|
|
1830
1165
|
if (((_b = (_a = this.loadedImage) === null || _a === void 0 ? void 0 : _a.transformed) === null || _b === void 0 ? void 0 : _b.image) != null) {
|
|
1831
1166
|
this.startCropImage.emit();
|
|
1832
|
-
/** @type {?} */
|
|
1833
1167
|
const output = this.cropService.crop(this.sourceImage, this.loadedImage, this.cropper, this.settings);
|
|
1834
1168
|
if (output != null) {
|
|
1835
1169
|
this.imageCropped.emit(output);
|
|
@@ -1839,243 +1173,133 @@ class ImageCropperComponent {
|
|
|
1839
1173
|
return null;
|
|
1840
1174
|
}
|
|
1841
1175
|
}
|
|
1842
|
-
ImageCropperComponent
|
|
1843
|
-
{ type:
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
]
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
]
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
}
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
ImageCropperComponent.prototype.imageChangedEvent;
|
|
1942
|
-
/** @type {?} */
|
|
1943
|
-
ImageCropperComponent.prototype.imageURL;
|
|
1944
|
-
/** @type {?} */
|
|
1945
|
-
ImageCropperComponent.prototype.imageBase64;
|
|
1946
|
-
/** @type {?} */
|
|
1947
|
-
ImageCropperComponent.prototype.imageFile;
|
|
1948
|
-
/** @type {?} */
|
|
1949
|
-
ImageCropperComponent.prototype.format;
|
|
1950
|
-
/** @type {?} */
|
|
1951
|
-
ImageCropperComponent.prototype.transform;
|
|
1952
|
-
/** @type {?} */
|
|
1953
|
-
ImageCropperComponent.prototype.maintainAspectRatio;
|
|
1954
|
-
/** @type {?} */
|
|
1955
|
-
ImageCropperComponent.prototype.aspectRatio;
|
|
1956
|
-
/** @type {?} */
|
|
1957
|
-
ImageCropperComponent.prototype.resizeToWidth;
|
|
1958
|
-
/** @type {?} */
|
|
1959
|
-
ImageCropperComponent.prototype.resizeToHeight;
|
|
1960
|
-
/** @type {?} */
|
|
1961
|
-
ImageCropperComponent.prototype.cropperMinWidth;
|
|
1962
|
-
/** @type {?} */
|
|
1963
|
-
ImageCropperComponent.prototype.cropperMinHeight;
|
|
1964
|
-
/** @type {?} */
|
|
1965
|
-
ImageCropperComponent.prototype.cropperMaxHeight;
|
|
1966
|
-
/** @type {?} */
|
|
1967
|
-
ImageCropperComponent.prototype.cropperMaxWidth;
|
|
1968
|
-
/** @type {?} */
|
|
1969
|
-
ImageCropperComponent.prototype.cropperStaticWidth;
|
|
1970
|
-
/** @type {?} */
|
|
1971
|
-
ImageCropperComponent.prototype.cropperStaticHeight;
|
|
1972
|
-
/** @type {?} */
|
|
1973
|
-
ImageCropperComponent.prototype.canvasRotation;
|
|
1974
|
-
/** @type {?} */
|
|
1975
|
-
ImageCropperComponent.prototype.initialStepSize;
|
|
1976
|
-
/** @type {?} */
|
|
1977
|
-
ImageCropperComponent.prototype.roundCropper;
|
|
1978
|
-
/** @type {?} */
|
|
1979
|
-
ImageCropperComponent.prototype.onlyScaleDown;
|
|
1980
|
-
/** @type {?} */
|
|
1981
|
-
ImageCropperComponent.prototype.imageQuality;
|
|
1982
|
-
/** @type {?} */
|
|
1983
|
-
ImageCropperComponent.prototype.autoCrop;
|
|
1984
|
-
/** @type {?} */
|
|
1985
|
-
ImageCropperComponent.prototype.backgroundColor;
|
|
1986
|
-
/** @type {?} */
|
|
1987
|
-
ImageCropperComponent.prototype.containWithinAspectRatio;
|
|
1988
|
-
/** @type {?} */
|
|
1989
|
-
ImageCropperComponent.prototype.hideResizeSquares;
|
|
1990
|
-
/** @type {?} */
|
|
1991
|
-
ImageCropperComponent.prototype.cropper;
|
|
1992
|
-
/** @type {?} */
|
|
1993
|
-
ImageCropperComponent.prototype.alignImage;
|
|
1994
|
-
/** @type {?} */
|
|
1995
|
-
ImageCropperComponent.prototype.disabled;
|
|
1996
|
-
/** @type {?} */
|
|
1997
|
-
ImageCropperComponent.prototype.imageCropped;
|
|
1998
|
-
/** @type {?} */
|
|
1999
|
-
ImageCropperComponent.prototype.startCropImage;
|
|
2000
|
-
/** @type {?} */
|
|
2001
|
-
ImageCropperComponent.prototype.imageLoaded;
|
|
2002
|
-
/** @type {?} */
|
|
2003
|
-
ImageCropperComponent.prototype.cropperReady;
|
|
2004
|
-
/** @type {?} */
|
|
2005
|
-
ImageCropperComponent.prototype.loadImageFailed;
|
|
2006
|
-
/**
|
|
2007
|
-
* @type {?}
|
|
2008
|
-
* @private
|
|
2009
|
-
*/
|
|
2010
|
-
ImageCropperComponent.prototype.cropService;
|
|
2011
|
-
/**
|
|
2012
|
-
* @type {?}
|
|
2013
|
-
* @private
|
|
2014
|
-
*/
|
|
2015
|
-
ImageCropperComponent.prototype.cropperPositionService;
|
|
2016
|
-
/**
|
|
2017
|
-
* @type {?}
|
|
2018
|
-
* @private
|
|
2019
|
-
*/
|
|
2020
|
-
ImageCropperComponent.prototype.loadImageService;
|
|
2021
|
-
/**
|
|
2022
|
-
* @type {?}
|
|
2023
|
-
* @private
|
|
2024
|
-
*/
|
|
2025
|
-
ImageCropperComponent.prototype.sanitizer;
|
|
2026
|
-
/**
|
|
2027
|
-
* @type {?}
|
|
2028
|
-
* @private
|
|
2029
|
-
*/
|
|
2030
|
-
ImageCropperComponent.prototype.cd;
|
|
2031
|
-
}
|
|
1176
|
+
ImageCropperComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ImageCropperComponent, deps: [{ token: CropService }, { token: CropperPositionService }, { token: LoadImageService }, { token: i4.DomSanitizer }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
1177
|
+
ImageCropperComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: ImageCropperComponent, selector: "image-cropper", inputs: { imageChangedEvent: "imageChangedEvent", imageURL: "imageURL", imageBase64: "imageBase64", imageFile: "imageFile", format: "format", transform: "transform", maintainAspectRatio: "maintainAspectRatio", aspectRatio: "aspectRatio", resizeToWidth: "resizeToWidth", resizeToHeight: "resizeToHeight", cropperMinWidth: "cropperMinWidth", cropperMinHeight: "cropperMinHeight", cropperMaxHeight: "cropperMaxHeight", cropperMaxWidth: "cropperMaxWidth", cropperStaticWidth: "cropperStaticWidth", cropperStaticHeight: "cropperStaticHeight", canvasRotation: "canvasRotation", initialStepSize: "initialStepSize", roundCropper: "roundCropper", onlyScaleDown: "onlyScaleDown", imageQuality: "imageQuality", autoCrop: "autoCrop", backgroundColor: "backgroundColor", containWithinAspectRatio: "containWithinAspectRatio", hideResizeSquares: "hideResizeSquares", cropper: "cropper", alignImage: "alignImage", disabled: "disabled" }, outputs: { imageCropped: "imageCropped", startCropImage: "startCropImage", imageLoaded: "imageLoaded", cropperReady: "cropperReady", loadImageFailed: "loadImageFailed" }, host: { listeners: { "window:resize": "onResize()", "document:mousemove": "moveImg($event)", "document:touchmove": "moveImg($event)", "document:mouseup": "moveStop()", "document:touchend": "moveStop()" }, properties: { "style.text-align": "this.alignImage", "class.disabled": "this.disabled" } }, viewQueries: [{ propertyName: "wrapper", first: true, predicate: ["wrapper"], descendants: true, static: true }, { propertyName: "sourceImage", first: true, predicate: ["sourceImage"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "<div [style.background]=\"imageVisible && backgroundColor\"\n #wrapper\n>\n <img\n #sourceImage\n class=\"ngx-ic-source-image\"\n *ngIf=\"safeImgDataUrl\"\n [src]=\"safeImgDataUrl\"\n [style.visibility]=\"imageVisible ? 'visible' : 'hidden'\"\n [style.transform]=\"safeTransformStyle\"\n (load)=\"imageLoadedInView()\"\n />\n <div\n class=\"ngx-ic-overlay\"\n [style.width.px]=\"maxSize.width\"\n [style.height.px]=\"maxSize.height\"\n [style.margin-left]=\"alignImage === 'center' ? marginLeft : null\"\n ></div>\n <div class=\"ngx-ic-cropper\"\n *ngIf=\"imageVisible\"\n [class.ngx-ic-round]=\"roundCropper\"\n [style.top.px]=\"cropper.y1\"\n [style.left.px]=\"cropper.x1\"\n [style.width.px]=\"cropper.x2 - cropper.x1\"\n [style.height.px]=\"cropper.y2 - cropper.y1\"\n [style.margin-left]=\"alignImage === 'center' ? marginLeft : null\"\n [style.visibility]=\"imageVisible ? 'visible' : 'hidden'\"\n (keydown)=\"keyboardAccess($event)\"\n tabindex=\"0\"\n >\n <div\n (mousedown)=\"startMove($event, moveTypes.Move)\"\n (touchstart)=\"startMove($event, moveTypes.Move)\"\n class=\"ngx-ic-move\">\n </div>\n <ng-container *ngIf=\"!hideResizeSquares\">\n <span class=\"ngx-ic-resize ngx-ic-topleft\"\n (mousedown)=\"startMove($event, moveTypes.Resize, 'topleft')\"\n (touchstart)=\"startMove($event, moveTypes.Resize, 'topleft')\">\n <span class=\"ngx-ic-square\"></span>\n </span>\n <span class=\"ngx-ic-resize ngx-ic-top\">\n <span class=\"ngx-ic-square\"></span>\n </span>\n <span class=\"ngx-ic-resize ngx-ic-topright\"\n (mousedown)=\"startMove($event, moveTypes.Resize, 'topright')\"\n (touchstart)=\"startMove($event, moveTypes.Resize, 'topright')\">\n <span class=\"ngx-ic-square\"></span>\n </span>\n <span class=\"ngx-ic-resize ngx-ic-right\">\n <span class=\"ngx-ic-square\"></span>\n </span>\n <span class=\"ngx-ic-resize ngx-ic-bottomright\"\n (mousedown)=\"startMove($event, moveTypes.Resize, 'bottomright')\"\n (touchstart)=\"startMove($event, moveTypes.Resize, 'bottomright')\">\n <span class=\"ngx-ic-square\"></span>\n </span>\n <span class=\"ngx-ic-resize ngx-ic-bottom\">\n <span class=\"ngx-ic-square\"></span>\n </span>\n <span class=\"ngx-ic-resize ngx-ic-bottomleft\"\n (mousedown)=\"startMove($event, moveTypes.Resize, 'bottomleft')\"\n (touchstart)=\"startMove($event, moveTypes.Resize, 'bottomleft')\">\n <span class=\"ngx-ic-square\"></span>\n </span>\n <span class=\"ngx-ic-resize ngx-ic-left\">\n <span class=\"ngx-ic-square\"></span>\n </span>\n <span class=\"ngx-ic-resize-bar ngx-ic-top\"\n (mousedown)=\"startMove($event, moveTypes.Resize, 'top')\"\n (touchstart)=\"startMove($event, moveTypes.Resize, 'top')\">\n </span>\n <span class=\"ngx-ic-resize-bar ngx-ic-right\"\n (mousedown)=\"startMove($event, moveTypes.Resize, 'right')\"\n (touchstart)=\"startMove($event, moveTypes.Resize, 'right')\">\n </span>\n <span class=\"ngx-ic-resize-bar ngx-ic-bottom\"\n (mousedown)=\"startMove($event, moveTypes.Resize, 'bottom')\"\n (touchstart)=\"startMove($event, moveTypes.Resize, 'bottom')\">\n </span>\n <span class=\"ngx-ic-resize-bar ngx-ic-left\"\n (mousedown)=\"startMove($event, moveTypes.Resize, 'left')\"\n (touchstart)=\"startMove($event, moveTypes.Resize, 'left')\">\n </span>\n </ng-container>\n </div>\n</div>\n", styles: [":host{display:flex;position:relative;width:100%;max-width:100%;max-height:100%;overflow:hidden;padding:5px;text-align:center}:host>div{width:100%;position:relative}:host>div img.ngx-ic-source-image{max-width:100%;max-height:100%;transform-origin:center}:host .ngx-ic-overlay{position:absolute;pointer-events:none;touch-action:none;outline:var(--cropper-overlay-color, white) solid 100vw;top:0;left:0}:host .ngx-ic-cropper{position:absolute;display:flex;color:#53535c;background:transparent;outline:rgba(255,255,255,.3) solid 100vw;outline:var(--cropper-outline-color, rgba(255, 255, 255, .3)) solid 100vw;touch-action:none}@media (orientation: portrait){:host .ngx-ic-cropper{outline-width:100vh}}:host .ngx-ic-cropper:after{position:absolute;content:\"\";top:0;bottom:0;left:0;right:0;pointer-events:none;border:dashed 1px;opacity:.75;color:inherit;z-index:1}:host .ngx-ic-cropper .ngx-ic-move{width:100%;cursor:move;border:1px solid rgba(255,255,255,.5)}:host .ngx-ic-cropper:focus .ngx-ic-move{border-color:#1e90ff;border-width:2px}:host .ngx-ic-cropper .ngx-ic-resize{position:absolute;display:inline-block;line-height:6px;padding:8px;opacity:.85;z-index:1}:host .ngx-ic-cropper .ngx-ic-resize .ngx-ic-square{display:inline-block;background:#53535C;width:6px;height:6px;border:1px solid rgba(255,255,255,.5);box-sizing:content-box}:host .ngx-ic-cropper .ngx-ic-resize.ngx-ic-topleft{top:-12px;left:-12px;cursor:nwse-resize}:host .ngx-ic-cropper .ngx-ic-resize.ngx-ic-top{top:-12px;left:calc(50% - 12px);cursor:ns-resize}:host .ngx-ic-cropper .ngx-ic-resize.ngx-ic-topright{top:-12px;right:-12px;cursor:nesw-resize}:host .ngx-ic-cropper .ngx-ic-resize.ngx-ic-right{top:calc(50% - 12px);right:-12px;cursor:ew-resize}:host .ngx-ic-cropper .ngx-ic-resize.ngx-ic-bottomright{bottom:-12px;right:-12px;cursor:nwse-resize}:host .ngx-ic-cropper .ngx-ic-resize.ngx-ic-bottom{bottom:-12px;left:calc(50% - 12px);cursor:ns-resize}:host .ngx-ic-cropper .ngx-ic-resize.ngx-ic-bottomleft{bottom:-12px;left:-12px;cursor:nesw-resize}:host .ngx-ic-cropper .ngx-ic-resize.ngx-ic-left{top:calc(50% - 12px);left:-12px;cursor:ew-resize}:host .ngx-ic-cropper .ngx-ic-resize-bar{position:absolute;z-index:1}:host .ngx-ic-cropper .ngx-ic-resize-bar.ngx-ic-top{top:-11px;left:11px;width:calc(100% - 22px);height:22px;cursor:ns-resize}:host .ngx-ic-cropper .ngx-ic-resize-bar.ngx-ic-right{top:11px;right:-11px;height:calc(100% - 22px);width:22px;cursor:ew-resize}:host .ngx-ic-cropper .ngx-ic-resize-bar.ngx-ic-bottom{bottom:-11px;left:11px;width:calc(100% - 22px);height:22px;cursor:ns-resize}:host .ngx-ic-cropper .ngx-ic-resize-bar.ngx-ic-left{top:11px;left:-11px;height:calc(100% - 22px);width:22px;cursor:ew-resize}:host .ngx-ic-cropper.ngx-ic-round{outline-color:transparent}:host .ngx-ic-cropper.ngx-ic-round:after{border-radius:100%;box-shadow:0 0 0 100vw #ffffff4d;box-shadow:0 0 0 100vw var(--cropper-outline-color, rgba(255, 255, 255, .3))}@media (orientation: portrait){:host .ngx-ic-cropper.ngx-ic-round:after{box-shadow:0 0 0 100vh #ffffff4d;box-shadow:0 0 0 100vh var(--cropper-outline-color, rgba(255, 255, 255, .3))}}:host .ngx-ic-cropper.ngx-ic-round .ngx-ic-move{border-radius:100%}:host.disabled .ngx-ic-cropper .ngx-ic-resize,:host.disabled .ngx-ic-cropper .ngx-ic-resize-bar,:host.disabled .ngx-ic-cropper .ngx-ic-move{display:none}\n"], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1178
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ImageCropperComponent, decorators: [{
|
|
1179
|
+
type: Component,
|
|
1180
|
+
args: [{ selector: 'image-cropper', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div [style.background]=\"imageVisible && backgroundColor\"\n #wrapper\n>\n <img\n #sourceImage\n class=\"ngx-ic-source-image\"\n *ngIf=\"safeImgDataUrl\"\n [src]=\"safeImgDataUrl\"\n [style.visibility]=\"imageVisible ? 'visible' : 'hidden'\"\n [style.transform]=\"safeTransformStyle\"\n (load)=\"imageLoadedInView()\"\n />\n <div\n class=\"ngx-ic-overlay\"\n [style.width.px]=\"maxSize.width\"\n [style.height.px]=\"maxSize.height\"\n [style.margin-left]=\"alignImage === 'center' ? marginLeft : null\"\n ></div>\n <div class=\"ngx-ic-cropper\"\n *ngIf=\"imageVisible\"\n [class.ngx-ic-round]=\"roundCropper\"\n [style.top.px]=\"cropper.y1\"\n [style.left.px]=\"cropper.x1\"\n [style.width.px]=\"cropper.x2 - cropper.x1\"\n [style.height.px]=\"cropper.y2 - cropper.y1\"\n [style.margin-left]=\"alignImage === 'center' ? marginLeft : null\"\n [style.visibility]=\"imageVisible ? 'visible' : 'hidden'\"\n (keydown)=\"keyboardAccess($event)\"\n tabindex=\"0\"\n >\n <div\n (mousedown)=\"startMove($event, moveTypes.Move)\"\n (touchstart)=\"startMove($event, moveTypes.Move)\"\n class=\"ngx-ic-move\">\n </div>\n <ng-container *ngIf=\"!hideResizeSquares\">\n <span class=\"ngx-ic-resize ngx-ic-topleft\"\n (mousedown)=\"startMove($event, moveTypes.Resize, 'topleft')\"\n (touchstart)=\"startMove($event, moveTypes.Resize, 'topleft')\">\n <span class=\"ngx-ic-square\"></span>\n </span>\n <span class=\"ngx-ic-resize ngx-ic-top\">\n <span class=\"ngx-ic-square\"></span>\n </span>\n <span class=\"ngx-ic-resize ngx-ic-topright\"\n (mousedown)=\"startMove($event, moveTypes.Resize, 'topright')\"\n (touchstart)=\"startMove($event, moveTypes.Resize, 'topright')\">\n <span class=\"ngx-ic-square\"></span>\n </span>\n <span class=\"ngx-ic-resize ngx-ic-right\">\n <span class=\"ngx-ic-square\"></span>\n </span>\n <span class=\"ngx-ic-resize ngx-ic-bottomright\"\n (mousedown)=\"startMove($event, moveTypes.Resize, 'bottomright')\"\n (touchstart)=\"startMove($event, moveTypes.Resize, 'bottomright')\">\n <span class=\"ngx-ic-square\"></span>\n </span>\n <span class=\"ngx-ic-resize ngx-ic-bottom\">\n <span class=\"ngx-ic-square\"></span>\n </span>\n <span class=\"ngx-ic-resize ngx-ic-bottomleft\"\n (mousedown)=\"startMove($event, moveTypes.Resize, 'bottomleft')\"\n (touchstart)=\"startMove($event, moveTypes.Resize, 'bottomleft')\">\n <span class=\"ngx-ic-square\"></span>\n </span>\n <span class=\"ngx-ic-resize ngx-ic-left\">\n <span class=\"ngx-ic-square\"></span>\n </span>\n <span class=\"ngx-ic-resize-bar ngx-ic-top\"\n (mousedown)=\"startMove($event, moveTypes.Resize, 'top')\"\n (touchstart)=\"startMove($event, moveTypes.Resize, 'top')\">\n </span>\n <span class=\"ngx-ic-resize-bar ngx-ic-right\"\n (mousedown)=\"startMove($event, moveTypes.Resize, 'right')\"\n (touchstart)=\"startMove($event, moveTypes.Resize, 'right')\">\n </span>\n <span class=\"ngx-ic-resize-bar ngx-ic-bottom\"\n (mousedown)=\"startMove($event, moveTypes.Resize, 'bottom')\"\n (touchstart)=\"startMove($event, moveTypes.Resize, 'bottom')\">\n </span>\n <span class=\"ngx-ic-resize-bar ngx-ic-left\"\n (mousedown)=\"startMove($event, moveTypes.Resize, 'left')\"\n (touchstart)=\"startMove($event, moveTypes.Resize, 'left')\">\n </span>\n </ng-container>\n </div>\n</div>\n", styles: [":host{display:flex;position:relative;width:100%;max-width:100%;max-height:100%;overflow:hidden;padding:5px;text-align:center}:host>div{width:100%;position:relative}:host>div img.ngx-ic-source-image{max-width:100%;max-height:100%;transform-origin:center}:host .ngx-ic-overlay{position:absolute;pointer-events:none;touch-action:none;outline:var(--cropper-overlay-color, white) solid 100vw;top:0;left:0}:host .ngx-ic-cropper{position:absolute;display:flex;color:#53535c;background:transparent;outline:rgba(255,255,255,.3) solid 100vw;outline:var(--cropper-outline-color, rgba(255, 255, 255, .3)) solid 100vw;touch-action:none}@media (orientation: portrait){:host .ngx-ic-cropper{outline-width:100vh}}:host .ngx-ic-cropper:after{position:absolute;content:\"\";top:0;bottom:0;left:0;right:0;pointer-events:none;border:dashed 1px;opacity:.75;color:inherit;z-index:1}:host .ngx-ic-cropper .ngx-ic-move{width:100%;cursor:move;border:1px solid rgba(255,255,255,.5)}:host .ngx-ic-cropper:focus .ngx-ic-move{border-color:#1e90ff;border-width:2px}:host .ngx-ic-cropper .ngx-ic-resize{position:absolute;display:inline-block;line-height:6px;padding:8px;opacity:.85;z-index:1}:host .ngx-ic-cropper .ngx-ic-resize .ngx-ic-square{display:inline-block;background:#53535C;width:6px;height:6px;border:1px solid rgba(255,255,255,.5);box-sizing:content-box}:host .ngx-ic-cropper .ngx-ic-resize.ngx-ic-topleft{top:-12px;left:-12px;cursor:nwse-resize}:host .ngx-ic-cropper .ngx-ic-resize.ngx-ic-top{top:-12px;left:calc(50% - 12px);cursor:ns-resize}:host .ngx-ic-cropper .ngx-ic-resize.ngx-ic-topright{top:-12px;right:-12px;cursor:nesw-resize}:host .ngx-ic-cropper .ngx-ic-resize.ngx-ic-right{top:calc(50% - 12px);right:-12px;cursor:ew-resize}:host .ngx-ic-cropper .ngx-ic-resize.ngx-ic-bottomright{bottom:-12px;right:-12px;cursor:nwse-resize}:host .ngx-ic-cropper .ngx-ic-resize.ngx-ic-bottom{bottom:-12px;left:calc(50% - 12px);cursor:ns-resize}:host .ngx-ic-cropper .ngx-ic-resize.ngx-ic-bottomleft{bottom:-12px;left:-12px;cursor:nesw-resize}:host .ngx-ic-cropper .ngx-ic-resize.ngx-ic-left{top:calc(50% - 12px);left:-12px;cursor:ew-resize}:host .ngx-ic-cropper .ngx-ic-resize-bar{position:absolute;z-index:1}:host .ngx-ic-cropper .ngx-ic-resize-bar.ngx-ic-top{top:-11px;left:11px;width:calc(100% - 22px);height:22px;cursor:ns-resize}:host .ngx-ic-cropper .ngx-ic-resize-bar.ngx-ic-right{top:11px;right:-11px;height:calc(100% - 22px);width:22px;cursor:ew-resize}:host .ngx-ic-cropper .ngx-ic-resize-bar.ngx-ic-bottom{bottom:-11px;left:11px;width:calc(100% - 22px);height:22px;cursor:ns-resize}:host .ngx-ic-cropper .ngx-ic-resize-bar.ngx-ic-left{top:11px;left:-11px;height:calc(100% - 22px);width:22px;cursor:ew-resize}:host .ngx-ic-cropper.ngx-ic-round{outline-color:transparent}:host .ngx-ic-cropper.ngx-ic-round:after{border-radius:100%;box-shadow:0 0 0 100vw #ffffff4d;box-shadow:0 0 0 100vw var(--cropper-outline-color, rgba(255, 255, 255, .3))}@media (orientation: portrait){:host .ngx-ic-cropper.ngx-ic-round:after{box-shadow:0 0 0 100vh #ffffff4d;box-shadow:0 0 0 100vh var(--cropper-outline-color, rgba(255, 255, 255, .3))}}:host .ngx-ic-cropper.ngx-ic-round .ngx-ic-move{border-radius:100%}:host.disabled .ngx-ic-cropper .ngx-ic-resize,:host.disabled .ngx-ic-cropper .ngx-ic-resize-bar,:host.disabled .ngx-ic-cropper .ngx-ic-move{display:none}\n"] }]
|
|
1181
|
+
}], ctorParameters: function () { return [{ type: CropService }, { type: CropperPositionService }, { type: LoadImageService }, { type: i4.DomSanitizer }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { wrapper: [{
|
|
1182
|
+
type: ViewChild,
|
|
1183
|
+
args: ['wrapper', { static: true }]
|
|
1184
|
+
}], sourceImage: [{
|
|
1185
|
+
type: ViewChild,
|
|
1186
|
+
args: ['sourceImage', { static: false }]
|
|
1187
|
+
}], imageChangedEvent: [{
|
|
1188
|
+
type: Input
|
|
1189
|
+
}], imageURL: [{
|
|
1190
|
+
type: Input
|
|
1191
|
+
}], imageBase64: [{
|
|
1192
|
+
type: Input
|
|
1193
|
+
}], imageFile: [{
|
|
1194
|
+
type: Input
|
|
1195
|
+
}], format: [{
|
|
1196
|
+
type: Input
|
|
1197
|
+
}], transform: [{
|
|
1198
|
+
type: Input
|
|
1199
|
+
}], maintainAspectRatio: [{
|
|
1200
|
+
type: Input
|
|
1201
|
+
}], aspectRatio: [{
|
|
1202
|
+
type: Input
|
|
1203
|
+
}], resizeToWidth: [{
|
|
1204
|
+
type: Input
|
|
1205
|
+
}], resizeToHeight: [{
|
|
1206
|
+
type: Input
|
|
1207
|
+
}], cropperMinWidth: [{
|
|
1208
|
+
type: Input
|
|
1209
|
+
}], cropperMinHeight: [{
|
|
1210
|
+
type: Input
|
|
1211
|
+
}], cropperMaxHeight: [{
|
|
1212
|
+
type: Input
|
|
1213
|
+
}], cropperMaxWidth: [{
|
|
1214
|
+
type: Input
|
|
1215
|
+
}], cropperStaticWidth: [{
|
|
1216
|
+
type: Input
|
|
1217
|
+
}], cropperStaticHeight: [{
|
|
1218
|
+
type: Input
|
|
1219
|
+
}], canvasRotation: [{
|
|
1220
|
+
type: Input
|
|
1221
|
+
}], initialStepSize: [{
|
|
1222
|
+
type: Input
|
|
1223
|
+
}], roundCropper: [{
|
|
1224
|
+
type: Input
|
|
1225
|
+
}], onlyScaleDown: [{
|
|
1226
|
+
type: Input
|
|
1227
|
+
}], imageQuality: [{
|
|
1228
|
+
type: Input
|
|
1229
|
+
}], autoCrop: [{
|
|
1230
|
+
type: Input
|
|
1231
|
+
}], backgroundColor: [{
|
|
1232
|
+
type: Input
|
|
1233
|
+
}], containWithinAspectRatio: [{
|
|
1234
|
+
type: Input
|
|
1235
|
+
}], hideResizeSquares: [{
|
|
1236
|
+
type: Input
|
|
1237
|
+
}], cropper: [{
|
|
1238
|
+
type: Input
|
|
1239
|
+
}], alignImage: [{
|
|
1240
|
+
type: HostBinding,
|
|
1241
|
+
args: ['style.text-align']
|
|
1242
|
+
}, {
|
|
1243
|
+
type: Input
|
|
1244
|
+
}], disabled: [{
|
|
1245
|
+
type: HostBinding,
|
|
1246
|
+
args: ['class.disabled']
|
|
1247
|
+
}, {
|
|
1248
|
+
type: Input
|
|
1249
|
+
}], imageCropped: [{
|
|
1250
|
+
type: Output
|
|
1251
|
+
}], startCropImage: [{
|
|
1252
|
+
type: Output
|
|
1253
|
+
}], imageLoaded: [{
|
|
1254
|
+
type: Output
|
|
1255
|
+
}], cropperReady: [{
|
|
1256
|
+
type: Output
|
|
1257
|
+
}], loadImageFailed: [{
|
|
1258
|
+
type: Output
|
|
1259
|
+
}], onResize: [{
|
|
1260
|
+
type: HostListener,
|
|
1261
|
+
args: ['window:resize']
|
|
1262
|
+
}], moveImg: [{
|
|
1263
|
+
type: HostListener,
|
|
1264
|
+
args: ['document:mousemove', ['$event']]
|
|
1265
|
+
}, {
|
|
1266
|
+
type: HostListener,
|
|
1267
|
+
args: ['document:touchmove', ['$event']]
|
|
1268
|
+
}], moveStop: [{
|
|
1269
|
+
type: HostListener,
|
|
1270
|
+
args: ['document:mouseup']
|
|
1271
|
+
}, {
|
|
1272
|
+
type: HostListener,
|
|
1273
|
+
args: ['document:touchend']
|
|
1274
|
+
}] } });
|
|
2032
1275
|
|
|
2033
|
-
/**
|
|
2034
|
-
* @fileoverview added by tsickle
|
|
2035
|
-
* Generated from: lib/image-cropper.module.ts
|
|
2036
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2037
|
-
*/
|
|
2038
1276
|
class ImageCropperModule {
|
|
2039
1277
|
}
|
|
2040
|
-
ImageCropperModule
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
1278
|
+
ImageCropperModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ImageCropperModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1279
|
+
ImageCropperModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ImageCropperModule, declarations: [ImageCropperComponent], imports: [CommonModule], exports: [ImageCropperComponent] });
|
|
1280
|
+
ImageCropperModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ImageCropperModule, imports: [[
|
|
1281
|
+
CommonModule
|
|
1282
|
+
]] });
|
|
1283
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ImageCropperModule, decorators: [{
|
|
1284
|
+
type: NgModule,
|
|
1285
|
+
args: [{
|
|
1286
|
+
imports: [
|
|
1287
|
+
CommonModule
|
|
1288
|
+
],
|
|
1289
|
+
declarations: [
|
|
1290
|
+
ImageCropperComponent
|
|
1291
|
+
],
|
|
1292
|
+
exports: [
|
|
1293
|
+
ImageCropperComponent
|
|
1294
|
+
]
|
|
1295
|
+
}]
|
|
1296
|
+
}] });
|
|
2053
1297
|
|
|
2054
|
-
/**
|
|
2055
|
-
* @fileoverview added by tsickle
|
|
2056
|
-
* Generated from: lib/interfaces/index.ts
|
|
2057
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2058
|
-
*/
|
|
2059
|
-
|
|
2060
|
-
/**
|
|
2061
|
-
* @fileoverview added by tsickle
|
|
2062
|
-
* Generated from: lib/utils/blob.utils.ts
|
|
2063
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2064
|
-
*/
|
|
2065
|
-
/**
|
|
2066
|
-
* @param {?} base64Image
|
|
2067
|
-
* @return {?}
|
|
2068
|
-
*/
|
|
2069
1298
|
function base64ToFile(base64Image) {
|
|
2070
|
-
/** @type {?} */
|
|
2071
1299
|
const split = base64Image.split(',');
|
|
2072
|
-
/** @type {?} */
|
|
2073
1300
|
const type = split[0].replace('data:', '').replace(';base64', '');
|
|
2074
|
-
/** @type {?} */
|
|
2075
1301
|
const byteString = atob(split[1]);
|
|
2076
|
-
/** @type {?} */
|
|
2077
1302
|
const ab = new ArrayBuffer(byteString.length);
|
|
2078
|
-
/** @type {?} */
|
|
2079
1303
|
const ia = new Uint8Array(ab);
|
|
2080
1304
|
for (let i = 0; i < byteString.length; i += 1) {
|
|
2081
1305
|
ia[i] = byteString.charCodeAt(i);
|
|
@@ -2084,16 +1308,8 @@ function base64ToFile(base64Image) {
|
|
|
2084
1308
|
}
|
|
2085
1309
|
|
|
2086
1310
|
/**
|
|
2087
|
-
*
|
|
2088
|
-
* Generated from: public-api.ts
|
|
2089
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2090
|
-
*/
|
|
2091
|
-
|
|
2092
|
-
/**
|
|
2093
|
-
* @fileoverview added by tsickle
|
|
2094
|
-
* Generated from: ngx-image-cropper.ts
|
|
2095
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1311
|
+
* Generated bundle index. Do not edit.
|
|
2096
1312
|
*/
|
|
2097
1313
|
|
|
2098
|
-
export { ImageCropperComponent, ImageCropperModule, base64ToFile, resizeCanvas
|
|
2099
|
-
//# sourceMappingURL=ngx-image-cropper.
|
|
1314
|
+
export { ImageCropperComponent, ImageCropperModule, base64ToFile, resizeCanvas };
|
|
1315
|
+
//# sourceMappingURL=ngx-image-cropper.mjs.map
|