mirror of
https://github.com/hyugogirubato/cbz.git
synced 2026-09-26 13:31:00 +00:00
Fix minimum player dimensions
This commit is contained in:
+12
-5
@@ -115,16 +115,23 @@ class Player:
|
|||||||
|
|
||||||
# Calculate scaling factors for width and height
|
# Calculate scaling factors for width and height
|
||||||
if self.comic_info.pages:
|
if self.comic_info.pages:
|
||||||
first_page = self.comic_info.pages[0]
|
# Get the minimum dimensions from all pages
|
||||||
scale_width = available_width / first_page.image_width
|
image_width = self.comic_info.pages[0].image_width
|
||||||
scale_height = available_height / first_page.image_height
|
image_height = self.comic_info.pages[0].image_height
|
||||||
|
for page in self.comic_info.pages[1:]:
|
||||||
|
if page.image_width <= image_width and page.image_height <= image_height:
|
||||||
|
image_width = page.image_width
|
||||||
|
image_height = page.image_height
|
||||||
|
|
||||||
|
scale_width = available_width / image_width
|
||||||
|
scale_height = available_height / image_height
|
||||||
|
|
||||||
# Choose the smaller scaling factor to maintain proportions
|
# Choose the smaller scaling factor to maintain proportions
|
||||||
scale_factor = min(scale_width, scale_height)
|
scale_factor = min(scale_width, scale_height)
|
||||||
|
|
||||||
# Calculate new dimensions
|
# Calculate new dimensions
|
||||||
initial_width = int(first_page.image_width * scale_factor * 0.94)
|
initial_width = int(image_width * scale_factor * 0.94)
|
||||||
initial_height = int(first_page.image_height * scale_factor)
|
initial_height = int(image_height * scale_factor)
|
||||||
else:
|
else:
|
||||||
initial_width = int(available_height * 0.63)
|
initial_width = int(available_height * 0.63)
|
||||||
initial_height = int(available_height)
|
initial_height = int(available_height)
|
||||||
|
|||||||
Reference in New Issue
Block a user