소스 검색

ImageEditor.jsx - remove 1px black lines (#4678)

Evgenia Karunus 1 년 전
부모
커밋
574209cced
1개의 변경된 파일11개의 추가작업 그리고 0개의 파일을 삭제
  1. 11 0
      packages/@uppy/image-editor/src/ImageEditor.jsx

+ 11 - 0
packages/@uppy/image-editor/src/ImageEditor.jsx

@@ -91,6 +91,17 @@ export default class ImageEditor extends UIPlugin {
 
     const { currentImage } = this.getPluginState()
 
+    // Fixes black 1px lines on odd-width images.
+    // This should be removed when cropperjs fixes this issue.
+    // (See https://github.com/transloadit/uppy/issues/4305 and https://github.com/fengyuanchen/cropperjs/issues/551).
+    const croppedCanvas = this.cropper.getCroppedCanvas({})
+    if (croppedCanvas.width % 2 !== 0) {
+      this.cropper.setData({ width: croppedCanvas.width - 1 })
+    }
+    if (croppedCanvas.height % 2 !== 0) {
+      this.cropper.setData({ height: croppedCanvas.height - 1 })
+    }
+
     this.cropper.getCroppedCanvas(this.opts.cropperOptions.croppedCanvasOptions).toBlob(
       saveBlobCallback,
       currentImage.type,