@syncfusion/ej2-image-editor 29.1.38 → 29.2.4

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.
Files changed (80) hide show
  1. package/dist/ej2-image-editor.umd.min.js +2 -2
  2. package/dist/ej2-image-editor.umd.min.js.map +1 -1
  3. package/dist/es6/ej2-image-editor.es2015.js +68 -9
  4. package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
  5. package/dist/es6/ej2-image-editor.es5.js +68 -9
  6. package/dist/es6/ej2-image-editor.es5.js.map +1 -1
  7. package/dist/global/ej2-image-editor.min.js +2 -2
  8. package/dist/global/ej2-image-editor.min.js.map +1 -1
  9. package/dist/global/index.d.ts +1 -1
  10. package/package.json +12 -12
  11. package/src/image-editor/action/draw.js +1 -0
  12. package/src/image-editor/base/image-editor-model.d.ts +25 -0
  13. package/src/image-editor/base/image-editor.d.ts +24 -0
  14. package/src/image-editor/base/image-editor.js +14 -0
  15. package/src/image-editor/renderer/toolbar.d.ts +1 -0
  16. package/src/image-editor/renderer/toolbar.js +53 -9
  17. package/styles/bds-lite.css +2 -2
  18. package/styles/bds.css +2 -2
  19. package/styles/bootstrap-dark-lite.css +2 -2
  20. package/styles/bootstrap-dark.css +2 -2
  21. package/styles/bootstrap-lite.css +2 -2
  22. package/styles/bootstrap.css +2 -2
  23. package/styles/bootstrap4-lite.css +2 -2
  24. package/styles/bootstrap4.css +2 -2
  25. package/styles/bootstrap5-dark-lite.css +2 -2
  26. package/styles/bootstrap5-dark.css +2 -2
  27. package/styles/bootstrap5-lite.css +2 -2
  28. package/styles/bootstrap5.3-lite.css +2 -2
  29. package/styles/bootstrap5.3.css +2 -2
  30. package/styles/bootstrap5.css +2 -2
  31. package/styles/fabric-dark-lite.css +2 -2
  32. package/styles/fabric-dark.css +2 -2
  33. package/styles/fabric-lite.css +2 -2
  34. package/styles/fabric.css +2 -2
  35. package/styles/fluent-dark-lite.css +2 -2
  36. package/styles/fluent-dark.css +2 -2
  37. package/styles/fluent-lite.css +2 -2
  38. package/styles/fluent.css +2 -2
  39. package/styles/fluent2-lite.css +2 -2
  40. package/styles/fluent2.css +2 -2
  41. package/styles/highcontrast-light-lite.css +2 -2
  42. package/styles/highcontrast-light.css +2 -2
  43. package/styles/highcontrast-lite.css +2 -2
  44. package/styles/highcontrast.css +2 -2
  45. package/styles/image-editor/_layout.scss +2 -2
  46. package/styles/image-editor/bds.css +2 -2
  47. package/styles/image-editor/bootstrap-dark.css +2 -2
  48. package/styles/image-editor/bootstrap.css +2 -2
  49. package/styles/image-editor/bootstrap4.css +2 -2
  50. package/styles/image-editor/bootstrap5-dark.css +2 -2
  51. package/styles/image-editor/bootstrap5.3.css +2 -2
  52. package/styles/image-editor/bootstrap5.css +2 -2
  53. package/styles/image-editor/fabric-dark.css +2 -2
  54. package/styles/image-editor/fabric.css +2 -2
  55. package/styles/image-editor/fluent-dark.css +2 -2
  56. package/styles/image-editor/fluent.css +2 -2
  57. package/styles/image-editor/fluent2.css +2 -2
  58. package/styles/image-editor/highcontrast-light.css +2 -2
  59. package/styles/image-editor/highcontrast.css +2 -2
  60. package/styles/image-editor/material-dark.css +2 -2
  61. package/styles/image-editor/material.css +2 -2
  62. package/styles/image-editor/material3-dark.css +2 -2
  63. package/styles/image-editor/material3.css +2 -2
  64. package/styles/image-editor/tailwind-dark.css +2 -2
  65. package/styles/image-editor/tailwind.css +2 -2
  66. package/styles/image-editor/tailwind3.css +2 -2
  67. package/styles/material-dark-lite.css +2 -2
  68. package/styles/material-dark.css +2 -2
  69. package/styles/material-lite.css +2 -2
  70. package/styles/material.css +2 -2
  71. package/styles/material3-dark-lite.css +2 -2
  72. package/styles/material3-dark.css +2 -2
  73. package/styles/material3-lite.css +2 -2
  74. package/styles/material3.css +2 -2
  75. package/styles/tailwind-dark-lite.css +2 -2
  76. package/styles/tailwind-dark.css +2 -2
  77. package/styles/tailwind-lite.css +2 -2
  78. package/styles/tailwind.css +2 -2
  79. package/styles/tailwind3-lite.css +2 -2
  80. package/styles/tailwind3.css +2 -2
@@ -3453,6 +3453,7 @@ class Draw {
3453
3453
  if (!parent.isUndoRedo) {
3454
3454
  parent.notify('filter', { prop: 'update-finetunes', onPropertyChange: false });
3455
3455
  }
3456
+ proxy.lowerContext.imageSmoothingQuality = parent.imageSmoothingEnabled ? 'high' : 'low';
3456
3457
  proxy.lowerContext.drawImage(parent.baseImg, 0, 0, proxy.parent.lowerCanvas.width, proxy.parent.lowerCanvas.height);
3457
3458
  let isCropped = false;
3458
3459
  let isSameDimension = false;
@@ -22370,6 +22371,17 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
22370
22371
  }
22371
22372
  this.updateDropInfoContent(this.element.querySelector('.e-ie-drop-info'));
22372
22373
  break;
22374
+ case 'imageSmoothingEnabled':
22375
+ if (newProperties.imageSmoothingEnabled) {
22376
+ this.imageSmoothingEnabled = true;
22377
+ this.lowerContext.imageSmoothingQuality = 'high';
22378
+ }
22379
+ else {
22380
+ this.imageSmoothingEnabled = false;
22381
+ this.lowerContext.imageSmoothingQuality = 'low';
22382
+ }
22383
+ this.notify('draw', { prop: 'render-image', value: { isMouseWheel: false } });
22384
+ break;
22373
22385
  }
22374
22386
  }
22375
22387
  }
@@ -26511,6 +26523,9 @@ __decorate([
26511
26523
  __decorate([
26512
26524
  Property()
26513
26525
  ], ImageEditor.prototype, "quickAccessToolbarTemplate", void 0);
26526
+ __decorate([
26527
+ Property(false)
26528
+ ], ImageEditor.prototype, "imageSmoothingEnabled", void 0);
26514
26529
  __decorate([
26515
26530
  Property(false)
26516
26531
  ], ImageEditor.prototype, "isReadOnly", void 0);
@@ -28610,6 +28625,47 @@ class ToolbarModule {
28610
28625
  ]
28611
28626
  });
28612
28627
  dialog.appendTo('#' + id + '_saveDialog');
28628
+ this.updateSavePreviewImage();
28629
+ }
28630
+ updateSavePreviewImage() {
28631
+ const parent = this.parent;
28632
+ const id = parent.element.id;
28633
+ const elem = parent.element.querySelector('#' + id + '_saveDialog');
28634
+ if (Browser.isDevice || !elem) {
28635
+ return;
28636
+ }
28637
+ const dialogWidth = elem.offsetWidth;
28638
+ const dialogMaxHeight = parseInt(elem.style.maxHeight, 10);
28639
+ const headerHeight = elem.querySelector('.e-dlg-header-content').offsetHeight;
28640
+ const footerHeight = elem.querySelector('.e-footer-content').offsetHeight;
28641
+ const padding = parseInt(window.getComputedStyle(elem.querySelector('#' + id + '_saveDialog_dialog-content')).padding, 10);
28642
+ const imageSizeContent = 20; // Image size text container div height
28643
+ const canvasMaxWidth = dialogWidth * (35 / 100); // 35% of dialog's width
28644
+ const canvasMaxHeight = dialogMaxHeight - headerHeight - footerHeight - imageSizeContent - (padding * 2);
28645
+ const canvas = parent.element.querySelector('#' + id + '_imgPic');
28646
+ const width = canvas.width;
28647
+ const height = canvas.height;
28648
+ const widthScale = canvasMaxWidth / width;
28649
+ const heightScale = canvasMaxHeight / height;
28650
+ let cssMaxWidth = Math.min(width, canvasMaxWidth);
28651
+ let cssMaxHeight = Math.min(height, canvasMaxHeight);
28652
+ if (widthScale < 1 && widthScale < heightScale) {
28653
+ cssMaxWidth = width * widthScale;
28654
+ cssMaxHeight = height * widthScale;
28655
+ }
28656
+ else if (heightScale < 1 && heightScale < widthScale) {
28657
+ cssMaxWidth = width * heightScale;
28658
+ cssMaxHeight = height * heightScale;
28659
+ }
28660
+ const imageObj = { canvas: null };
28661
+ parent.notify('export', { prop: 'exportToCanvas', value: { object: imageObj } });
28662
+ const ctx = canvas.getContext('2d');
28663
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
28664
+ canvas.width = cssMaxWidth;
28665
+ canvas.height = cssMaxHeight;
28666
+ const tempCanvas = imageObj['canvas'];
28667
+ ctx.imageSmoothingQuality = 'medium';
28668
+ ctx.drawImage(tempCanvas, 0, 0, tempCanvas.width, tempCanvas.height, 0, 0, cssMaxWidth, cssMaxHeight);
28613
28669
  }
28614
28670
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
28615
28671
  saveDialogClosed(id) {
@@ -28709,6 +28765,7 @@ class ToolbarModule {
28709
28765
  this.updateImageSize(isNullOrUndefined(this.currentQuality) ? 1 : this.currentQuality, obj['canvas'], this.fileType);
28710
28766
  document.getElementById(id + '_' + this.imageQuality).checked = true;
28711
28767
  }
28768
+ this.updateSavePreviewImage();
28712
28769
  }
28713
28770
  });
28714
28771
  drpDownBtn.appendTo('#' + id + '_saveDropdownbtn');
@@ -28763,12 +28820,14 @@ class ToolbarModule {
28763
28820
  created: () => {
28764
28821
  this.updateImageSize(this.currentQuality, obj['canvas'], 'jpeg');
28765
28822
  qualitySliderValueSpan.innerHTML = (Math.round(this.currentQuality * 100)).toString();
28823
+ this.updateSavePreviewImage();
28766
28824
  },
28767
28825
  changed: (args) => {
28768
28826
  this.currentQuality = args.value;
28769
28827
  qualitySliderValueSpan.innerHTML = (Math.round(this.currentQuality * 100)).toString();
28770
28828
  parent.notify('export', { prop: 'setImageQuality', value: { value: args.value } });
28771
28829
  this.updateImageSize(args.value, obj['canvas'], 'jpeg');
28830
+ this.updateSavePreviewImage();
28772
28831
  }
28773
28832
  });
28774
28833
  sliderObj.appendTo('#' + id + '_qualitySlider');
@@ -28789,6 +28848,7 @@ class ToolbarModule {
28789
28848
  this.currentQuality = compressionValues[target.textContent];
28790
28849
  this.imageQuality = target.textContent.toLowerCase();
28791
28850
  this.updateImageSize(compressionValues[target.textContent], obj['canvas'], 'jpeg');
28851
+ this.updateSavePreviewImage();
28792
28852
  }
28793
28853
  }
28794
28854
  updateImageSize(quality, tempCanvas, fileType) {
@@ -28805,7 +28865,11 @@ class ToolbarModule {
28805
28865
  else {
28806
28866
  imageNameLabel = document.getElementById(id + '_imageNameLabel');
28807
28867
  }
28868
+ const imageSmoothingEnabled = parent.imageSmoothingEnabled;
28869
+ ctx.canvas.getContext('2d').imageSmoothingQuality = imageSmoothingEnabled ? 'high' : 'low';
28808
28870
  if (fileType.toLowerCase() === 'jpeg') {
28871
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
28872
+ ctx.drawImage(tempCanvas, 0, 0);
28809
28873
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
28810
28874
  tempCanvas.toBlob((function (blob) {
28811
28875
  fileSize = Math.floor(blob.size / 1024);
@@ -28821,20 +28885,12 @@ class ToolbarModule {
28821
28885
  if (Browser.isDevice) {
28822
28886
  canvas.style.display = 'none';
28823
28887
  }
28824
- else {
28825
- const compressedImage = new Image();
28826
- compressedImage.src = URL.createObjectURL(blob);
28827
- // eslint-disable-next-line @typescript-eslint/tslint/config
28828
- compressedImage.onload = function () {
28829
- ctx.drawImage(compressedImage, 0, 0);
28830
- URL.revokeObjectURL(compressedImage.src);
28831
- };
28832
- }
28833
28888
  this.fileSize = fileSize;
28834
28889
  }).bind(this), 'image/jpeg', quality);
28835
28890
  }
28836
28891
  else if (!isNullOrUndefined(fileType) && (fileType.toLowerCase() === 'png' || fileType.toLowerCase() === 'webp')) {
28837
28892
  const type = 'image/' + fileType.toLowerCase();
28893
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
28838
28894
  ctx.drawImage(tempCanvas, 0, 0);
28839
28895
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
28840
28896
  tempCanvas.toBlob((function (blob) {
@@ -28855,6 +28911,7 @@ class ToolbarModule {
28855
28911
  }).bind(this), type, 1);
28856
28912
  }
28857
28913
  else if (!isNullOrUndefined(fileType) && fileType.toLowerCase() === 'svg') {
28914
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
28858
28915
  ctx.drawImage(tempCanvas, 0, 0);
28859
28916
  const svgDataUrl = tempCanvas.toDataURL('image/svg+xml');
28860
28917
  const base64Data = svgDataUrl.split(',')[1];
@@ -28880,6 +28937,7 @@ class ToolbarModule {
28880
28937
  canvas.style.display = 'none';
28881
28938
  }
28882
28939
  else {
28940
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
28883
28941
  ctx.drawImage(tempCanvas, 0, 0);
28884
28942
  if (this.initialSize > 1000) {
28885
28943
  const megabytes = this.initialSize / 1048576;
@@ -31525,6 +31583,7 @@ class ToolbarModule {
31525
31583
  if (filter) {
31526
31584
  let ctx = filter.getContext('2d');
31527
31585
  ctx = filter.getContext('2d');
31586
+ ctx.imageSmoothingQuality = parent.imageSmoothingEnabled ? 'high' : 'low';
31528
31587
  filter.style.width = '100px';
31529
31588
  filter.style.height = '100px';
31530
31589
  parent.notify('filter', { prop: 'updateAdj', value: { type: type, value: null, isPreview: true, ctx: ctx } });