Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: getImage.crop is not a function #783

Open
TruongNoDame opened this issue Dec 6, 2023 · 0 comments
Open

Uncaught TypeError: getImage.crop is not a function #783

TruongNoDame opened this issue Dec 6, 2023 · 0 comments

Comments

@TruongNoDame
Copy link

The code I get this error is: const crop = imageSrc.crop({ x: value.x / ratio_w, y: value.y / ratio_h, width: value.width / ratio_w, height: value.height / ratio_h });
I got this error when I was trying to get a subimage with the x,y, width and height coordinates of the image area to get. In there I declare const [imageSrc, setImageSrc] = useState(null), and I update the value of imageSrc here:

const handleImageChange = (event) => {
         const file = event.target.files[0];
         if (file) {
             const reader = new FileReader();
             reader.onloadend = () => {
                 setImageSrc(reader.result)
             };
             reader.readAsDataURL(file);
         }
     };

According to Konva's documentation, there are instructions:

/ get crop
var crop = image.crop();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant