react-image-crop icon indicating copy to clipboard operation
react-image-crop copied to clipboard

Not able to catch exact crop image

Open iamkashhif opened this issue 2 years ago • 1 comments

when I am getting the Final Crop image, not equal matching my crop area image, let me know, if i am doing wrong

also its not working in macBook.

image

const handleCropComplete = (crop: any) => {
    setCompletedCrop(crop);
    if (crop.width && crop.height) {
      // Generate the cropped image data URL
      const image = new Image();
      image.src = ProfileImage;
      const canvas = document.createElement("canvas");
      canvas.width = crop.width;
      canvas.height = crop.height;
      const ctx = canvas.getContext("2d");

      if (ctx) {
        ctx.drawImage(
          image,
          crop.x,
          crop.y,
          crop.width,
          crop.height,
          0,
          0,
          crop.width,
          crop.height
        );

        const croppedDataURL: any = canvas.toDataURL("image/jpeg");
        setCroppedImage(croppedDataURL);
      }
    }
  };

iamkashhif avatar Oct 26 '23 11:10 iamkashhif

I'm having exactly the same issue after bumping up from v8 to v11 (when img src got introduced as a children).

Did some digging by resizing my image to the same image as my modal for cropping and it worked almost fine.

So it seems to me it's cropping the original image while not taking into the factor scaled down coordinates, like maybe part of the code is not being fired at all?

Wild guess though.

MrSala avatar Feb 20 '24 03:02 MrSala