I am creating Image Viewer app using python and tkinter for gui. I want to save image part that is inside the canvas and save it in binary file. Sometimes it works fine, but sometimes i get that image but its distorted and its like u cut right part of that image and switch its place with the rest of it. This is how i get coords and crop image:
x1=max(-self.current_x/self.zoom_factor,0)
y1=max(-self.current_y/self.zoom_factor,0)
x2 = min(x1 + self.canvas.winfo_width()/self.zoom_factor, self.image.width)
y2 = min(y1 + self.canvas.winfo_height()/self.zoom_factor, self.image.height)
cropped_image = self.image.crop((x1, y1, x2, y2))