aspect ratio and keep awake
This commit is contained in:
@ -17,7 +17,9 @@ that maximizes each printed photo's area on a fixed 8.5x11 letter sheet
|
||||
a strip has few photos and a wide page fills better
|
||||
(e.g. 1 photo per shoot, or one big photo).
|
||||
|
||||
The date is printed only inside the footer.
|
||||
The date is printed only inside the footer. Sheets are saved with 300-DPI
|
||||
metadata so their physical print size is well-defined (a full letter page)
|
||||
for CUPS or any other program they are printed from.
|
||||
"""
|
||||
|
||||
import subprocess
|
||||
@ -229,13 +231,24 @@ def build_sheet(photo_paths, out_path, footer_cfg=None,
|
||||
for (x, y, w, h) in layout["footer_rects"]:
|
||||
sheet.paste(footer_img, (x, y))
|
||||
|
||||
sheet.save(out_path, quality=95)
|
||||
# Stamp 300 DPI into the file: without it the sheet has no defined
|
||||
# physical size and the print pipeline has to guess (and may stretch).
|
||||
sheet.save(out_path, quality=95, dpi=(300, 300))
|
||||
return out_path
|
||||
|
||||
|
||||
def print_sheet(path, printer=""):
|
||||
"""Send the sheet to the printer via lp. Returns (ok, message)."""
|
||||
cmd = ["lp", "-o", "media=letter", "-o", "fit-to-page"]
|
||||
"""Send the sheet to the printer via lp. Returns (ok, message).
|
||||
|
||||
fit-to-page scales uniformly, so the sheet's aspect ratio is preserved.
|
||||
Passing the sheet's orientation explicitly keeps a landscape sheet from
|
||||
being rotated or squeezed by driver defaults.
|
||||
"""
|
||||
with Image.open(path) as im:
|
||||
sheet_w, sheet_h = im.size
|
||||
orientation = "landscape" if sheet_w > sheet_h else "portrait"
|
||||
cmd = ["lp", "-o", "media=letter", "-o", "fit-to-page",
|
||||
"-o", orientation]
|
||||
if printer:
|
||||
cmd += ["-d", printer]
|
||||
cmd.append(str(path))
|
||||
|
||||
Reference in New Issue
Block a user