From 43a3c3486745d29094ef2643b61aa987086c3907 Mon Sep 17 00:00:00 2001 From: Jeena Date: Mon, 6 Sep 2021 10:19:12 +0900 Subject: [PATCH] Don't crop if picture too small --- edit.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/edit.py b/edit.py index 804ffa3..5ebed89 100755 --- a/edit.py +++ b/edit.py @@ -66,7 +66,8 @@ class Image: # center zoom x = self.image.shape[1]/2 - self.w/2 y = self.image.shape[0]/2 - self.h/2 - self.image = self.image[int(y):int(y+self.h), int(x):int(x+self.w)] + if x > 0 and y > 0: + self.image = self.image[int(y):int(y+self.h), int(x):int(x+self.w)] def safe(self, new_path): cv2.imwrite(new_path, self.image)