我遵循了本教程,这就是我到目前为止所提出的:
#!/usr/bin/python
# -*- coding: utf-8 -*-
#http://www.ibm.com/developerworks/library/os-autogimp/
from gimpfu import*
def plugin_main(timg, tdrawable, maxh=540, maxw=800):
currentWidth = tdrawable.width
currentHeight = tdrawable.height
newWidth = currentWidth
newHeight = currentHeight
if (maxw < newWidth):
newWidth = maxw
newHeight = (float(currentHeight) / (float(currentWidth) / newWidth))
if (maxh < newHeight):
newHeight = maxh
newWidth = (float(currentWidth) / (float(currentHeight) / newHeight))
pdb.gimp_image_scale(timg, newWidth, newHeight)
register(
"python_fu_resize",
"Saves the image at a maximum width and height",
"Saves the image at a maximum width and height",
"N N",
"N N",
"2013",
"<Image>/Image/Resize to max...",
"*",
[],
[],
plugin_main)
main()
但是插件不会出现在 gimp 菜单中(我使用的是 gimp 2.8)。授予文件 chmod a+x 权限。文件位置可能有问题:/.gimp-2.8/plug-ins/src/resize.py?src 是因为 Eclipse。