Make more use of function mm_to_pixel.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 5 Jun 2019 04:12:41 +0000 (06:12 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 5 Jun 2019 04:12:41 +0000 (06:12 +0200)
gimp_passport.py

index 3e19cc9..8b82675 100644 (file)
@@ -44,8 +44,8 @@ def make_passport(img_rgba: Image, fpr: float, width_mm: float, height_mm: float
 
 def tile(img: Image, paper_width_mm: float, paper_height_mm: float, margin_mm: float) -> Image:
     dpi = img.info['dpi'][0]
-    paper_width_pixel = int(round(paper_width_mm / MM_PER_INCH * dpi))
-    paper_height_pixel = int(round(paper_height_mm / MM_PER_INCH * dpi))
+    paper_width_pixel = mm_to_pixel(paper_width_mm, dpi)
+    paper_height_pixel = mm_to_pixel(paper_height_mm, dpi)
     margin_pixel = mm_to_pixel(margin_mm, dpi)
     paper = Image.new('RGB', (paper_width_pixel, paper_height_pixel), 'white')
     paper.info['dpi'] = (dpi, dpi)