Expose all parameters to GIMP.
[toast/gimp_passport.git] / gimp_passport_plugin.py
index 1ed2038..c677523 100755 (executable)
@@ -5,7 +5,8 @@ import PIL.Image
 import gimp_passport
 
 
 import gimp_passport
 
 
-def create_passport(image, drawable, paper_height_mm, paper_width_mm, fpr):
+def create_passport(image, drawable, paper_width_mm, paper_height_mm, margin_mm, photo_width_mm,
+                    photo_height_mm, spacing_mm, fpr, max_dpi):
     # Note: for interactive sessions you can get the image via:
     # image = gimp.image_list()[0]
     # drawable = pdb.gimp_image_get_active_drawable(image)
     # Note: for interactive sessions you can get the image via:
     # image = gimp.image_list()[0]
     # drawable = pdb.gimp_image_get_active_drawable(image)
@@ -20,18 +21,13 @@ def create_passport(image, drawable, paper_height_mm, paper_width_mm, fpr):
     # pdb.gimp_image_get_guide_orientation(image, 6)
     # pdb.gimp_image_get_guide_position(image, 6)
 
     # pdb.gimp_image_get_guide_orientation(image, 6)
     # pdb.gimp_image_get_guide_position(image, 6)
 
-    photo_width_mm = 35.
-    photo_height_mm = 45.
-    margin_mm = 4.
-    spacing_mm = 1.
-
     # convert GIMP image to PIL image:
     rgn = drawable.get_pixel_rgn(0, 0, drawable.width, drawable.height)
     pil_img = PIL.Image.frombytes('RGB', (drawable.width, drawable.height), rgn[:, :])
 
     # perform processing
     pil_paper = gimp_passport.process(paper_width_mm, paper_height_mm, margin_mm, photo_width_mm, photo_height_mm, spacing_mm, 
     # convert GIMP image to PIL image:
     rgn = drawable.get_pixel_rgn(0, 0, drawable.width, drawable.height)
     pil_img = PIL.Image.frombytes('RGB', (drawable.width, drawable.height), rgn[:, :])
 
     # perform processing
     pil_paper = gimp_passport.process(paper_width_mm, paper_height_mm, margin_mm, photo_width_mm, photo_height_mm, spacing_mm, 
-                                      fpr, None, (left, top, right, bottom), pil_img)
+                                      fpr, max_dpi, (left, top, right, bottom), pil_img)
 
     # copy processed PIL to new GIMP image
     image_new = pdb.gimp_image_new(pil_paper.width, pil_paper.height, pdb.gimp_image_base_type(image))
 
     # copy processed PIL to new GIMP image
     image_new = pdb.gimp_image_new(pil_paper.width, pil_paper.height, pdb.gimp_image_base_type(image))
@@ -53,9 +49,14 @@ register(
         "<Image>/Filters/Map/Create _Passport...",
         "RGB*, GRAY*",
         [
         "<Image>/Filters/Map/Create _Passport...",
         "RGB*, GRAY*",
         [
-            (PF_INT, "paper_height_mm", "Paper height in mm", 100),
-            (PF_INT, "paper_width_mm", "Paper width in mm", 150),
+            (PF_FLOAT, "paper_width_mm", "Paper width in mm", 150.),
+            (PF_FLOAT, "paper_height_mm", "Paper height in mm", 100.),
+            (PF_FLOAT, "margin_mm", "Paper margin in mm", 4.),
+            (PF_FLOAT, "photo_width_mm", "Passport photo width in mm", 35.),
+            (PF_FLOAT, "photo_height_mm", "Passport photo height in mm", 45.),
+            (PF_FLOAT, "spacing_mm", "Space between passport photos in mm", 1.),
             (PF_FLOAT, "fpr", "Face to picture ratio", 0.75),
             (PF_FLOAT, "fpr", "Face to picture ratio", 0.75),
+            (PF_INT, "max_dpi", "Maximum dots per inch", 600),
         ],
         [
             (PF_IMAGE, "image", "passport image for printout"),
         ],
         [
             (PF_IMAGE, "image", "passport image for printout"),