这个插件在我单独运行时工作正常,但是当我将它作为一个过程添加到 Batch Image Manipulation Plugin (BIMP) 时,它只输出 412x316 的图像,没有我想要的 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()
我正在努力使 412x316 图像周围有一个透明边框,使图像成为 640x360.