help with Canvas api for cropping an image

https://codesandbox.io/s/exciting-lederberg-t3df9x?file=/index.html Looking for help with a crop image feature for images . The issue is the image moves to top left corner to default coordinates (0,0) but when i use translate method to centre the image , as it doesn't calculate the selected crop area coordinates correctly. The image should remain centered, but when attempting to crop the area selected by the crosshair, it ends up cropping some other coordinates instead(it calculates coordinates according to canvas not the image). The problem seems to be related to handling image aspect ratio, especially when the image height is greater than the width, leading to unexpected zooming. Any guidance or assistance on resolving this issue would be appreciated. Thank you!
thewinkercoder888
CodeSandbox
exciting-lederberg-t3df9x - CodeSandbox
exciting-lederberg-t3df9x by thewinkercoder888 using parcel-bundler
0 Replies
No replies yetBe the first to reply to this messageJoin