Don't crop if picture too small

This commit is contained in:
Jeena 2021-09-06 10:19:12 +09:00
parent c5d8fbf6e8
commit 43a3c34867

View file

@ -66,7 +66,8 @@ class Image:
# center zoom # center zoom
x = self.image.shape[1]/2 - self.w/2 x = self.image.shape[1]/2 - self.w/2
y = self.image.shape[0]/2 - self.h/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): def safe(self, new_path):
cv2.imwrite(new_path, self.image) cv2.imwrite(new_path, self.image)