1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-13 01:36:27 +00:00

Add preserve margin % toggle (#886)

* preserve margin

* set ratio to 0.5

* add preserve margin GUI

* increase step size to 5

* remove clear

* fix save

* save preserveMarginBox

* math

* max 99
This commit is contained in:
Alex Xu
2025-04-03 10:11:14 -07:00
committed by GitHub
parent 41f87273ca
commit 3e3710dd76
7 changed files with 103 additions and 41 deletions

View File

@@ -390,6 +390,11 @@ class ComicPage:
return Image.Resampling.LANCZOS
def maybeCrop(self, box, minimum):
w, h = self.image.size
left, upper, right, lower = box
if self.opt.preservemargin:
ratio = 1 - self.opt.preservemargin / 100
box = left * ratio, upper * ratio, right + (w - right) * (1 - ratio), lower + (h - lower) * (1 - ratio)
box_area = (box[2] - box[0]) * (box[3] - box[1])
image_area = self.image.size[0] * self.image.size[1]
if (box_area / image_area) >= minimum: