This plug-in works fine when I run it by itself, but when I add it as a procedure to Batch Image Manipulation Plugin (BIMP), it only outputs the image as 412x316 without the borders that I want at 640x360.
from gimpfu import *
def resize_canvas(image, drawable):
# Resize the image
pdb.gimp_image_scale(image, 412, 316)
# Get the new width and height of the image
width, height = pdb.gimp_image_width(image), pdb.gimp_image_height(image)
# Change the canvas size
pdb.gimp_image_resize(image, 640, 360, 0, 0)
# Calculate the x and y coordinates to center the image
x = (640 - width) / 2
y = (360 - height) / 2
# Center the image on the canvas
pdb.gimp_layer_set_offsets(drawable, x, y)
register(
"python_fu_resize_canvas",
"Resize and center an image",
"Resize an image and center it on a canvas",
"Name",
"Name",
"2023",
"Resize and Center",
"",
[
(PF_IMAGE, "image", "Input image", None),
(PF_DRAWABLE, "drawable", "Input drawable", None)
],
[],
resize_canvas,
menu="<Image>/Filters/Misc"
)
main()
I'm trying to make it so there's a transparent border around the 412x316 image that makes the image 640x360.