Skip to content

Commit

Permalink
cleanup comments
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicWindisch committed Feb 21, 2024
1 parent 2527263 commit 6679dca
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions photobooth/services/mediaprocessing/print_pipelinestages.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def fit_image(self, image: ImageRect):

self.image_list.append(image)

# update space left
# update reamining space on this page
if image.width == self.width:
self.min_y += image.height + self.spacing
if image.height == self.height:
Expand Down Expand Up @@ -74,7 +74,7 @@ def add_image(self, image_width, image_height, image_id):

def create_layout(self):
"""Try to find a page into which the image can be fit. If there is none, create a new page."""
# iterate images

for image in self.image_list:
image_ok = False
for page in self.page_list:
Expand All @@ -98,7 +98,7 @@ def merge_print_items_stage(
1. Rotate the image to fit the print mediums aspect ratio
2. Resize the image to fill the print mediums complete height or width
3. Automatically distribute these images amongst however many pages needed
4. Returns a list of images (one per page) to print
4. Create a new image for each page from the layout
Arguments:
print_items: list of the images to print
Expand All @@ -111,13 +111,10 @@ def merge_print_items_stage(
list of images (one per page) to print
"""

# fit images into a given page size
# if necessary, return multiple pages to print

# setup page canvas
page_width_px = int((page_width_mm * dpi) / 25.4)
page_height_px = int((page_height_mm * dpi) / 25.4)
item_spacing_px = int((item_spacing_mm * dpi) / 25.4)
page_width_px = int(round((page_width_mm * dpi) / 25.4))
page_height_px = int(round((page_height_mm * dpi) / 25.4))
item_spacing_px = int(round((item_spacing_mm * dpi) / 25.4))
page_orientation_landscape = page_width_mm > page_height_mm

auto_layout = AutoLayoutCreator(page_width_px, page_height_px, item_spacing_px)
Expand All @@ -126,7 +123,7 @@ def merge_print_items_stage(
for index, item in enumerate(print_items):
_image = item

# resize items to fill page optimally.
# resize items to fill page optimally
item_orientation_landscape: bool = _image.width > _image.height

if item_orientation_landscape != page_orientation_landscape:
Expand All @@ -150,7 +147,7 @@ def merge_print_items_stage(

pages: list[Image.Image] = []
for page_num, page_layout in enumerate(page_layouts):
logger.info(f"Items on page {page_num} ({page_layout.width}x{page_layout.height}): ") # Bin id if it has one
logger.info(f"Items on page {page_num} ({page_layout.width}x{page_layout.height}): ")

pages.append(Image.new("RGB", (page_width_px, page_height_px), "white")) # empty page, white to not print anything on empty space

Expand Down

0 comments on commit 6679dca

Please sign in to comment.