The new image now has only one layer.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Thu, 20 Jun 2019 21:35:44 +0000 (23:35 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Thu, 20 Jun 2019 21:35:44 +0000 (23:35 +0200)
gimp_passport_plugin.py

index 863d78c..26abbb4 100755 (executable)
@@ -24,11 +24,11 @@ def create_passport(image, drawable, paper_height_mm, paper_width_mm):
     pil_img = pil_img.transpose(PIL.Image.ROTATE_180)
 
     # copy processed PIL to new GIMP image
-    image_new = pdb.gimp_image_duplicate(image)
-    layer = gimp.Layer(image_new, "myname", image_new.width, image_new.height, image.active_layer.type, 100, NORMAL_MODE)
+    image_new = pdb.gimp_image_new(pil_img.width, pil_img.height, pdb.gimp_image_base_type(image))
+    layer = gimp.Layer(image_new, "passport", image_new.width, image_new.height, pdb.gimp_image_base_type(image), 100, NORMAL_MODE)
+    image_new.add_layer(layer)
     rgn = layer.get_pixel_rgn(0, 0, layer.width, layer.height, True)
     rgn[:, :] = pil_img.tobytes()
-    image_new.add_layer(layer)
     gimp.Display(image_new)
     return image_new