GIMP使您能够在Python中创建插件,我想要做的就是调用GIMP函数,就像我在其中一个插件中所做的那样,但这会返回以下错误,因为GIMP没有找到任何正在运行的GIMP Core.
LibGimpBase-ERROR **: gimp_wire_write_msg: the wire protocol has not been initialized aborting...
Run Code Online (Sandbox Code Playgroud)
我想知道它是否可能?如果是,怎么样?
谢谢
我遵循了本教程,这是我到目前为止所得到的:
#!/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 …
Run Code Online (Sandbox Code Playgroud) 随着GIMP福,我能救的内容一个层(至少,这就是我interprete的定义,gimp_file_save
因为它需要的参数drawable
).
现在,我有以下脚本:
from gimpfu import *
def write_text():
width = 400
height = 100
img = gimp.Image(width, height, RGB)
img.disable_undo()
gimp.set_foreground( (255, 100, 20) )
gimp.set_background( ( 0, 15, 40) )
background_layer = gimp.Layer(
img,
'Background',
width,
height,
RGB_IMAGE,
100,
NORMAL_MODE)
img.add_layer(background_layer, 0)
background_layer.fill(BACKGROUND_FILL)
text_layer = pdb.gimp_text_fontname(
img,
None,
60,
40,
'Here is some text',
0,
True,
30,
PIXELS,
'Courier New'
)
drawable = pdb.gimp_image_active_drawable(img)
# Either export text layer ...
# pdb.gimp_file_save(img, drawable, …
Run Code Online (Sandbox Code Playgroud) 从gimp.org下载使用Gimp 2.6.6 for MAC OS X(在X11下).
我正在尝试使用Script-Fu自动化无聊的手动过程.我需要解析图像文件名以使用原始文件名上的后缀将各种图层保存为新文件.
我最初的尝试是这样的,但失败了,因为(string-search ...)
似乎在2.6下没有(脚本引擎的更改?).
(set! basefilename (substring filename 0 (string-search "." filename)))
Run Code Online (Sandbox Code Playgroud)
然后我尝试使用此信息使用正则表达式解析基本文件名,但(re-match-nth ...)
也无法识别.
(if (re-match "^(.*)[.]([^.]+)$" filename buffer)
(set! basefilename (re-match-nth orig-name buffer 1))
)
Run Code Online (Sandbox Code Playgroud)
虽然从向量中拉出值没有错误,但在传入时,结果值不会被视为字符串(string-append ...)
.
(if (re-match "^(.*)[.]([^.]+)$" filename buffer)
(set! basefilename (vector-ref buffer 1))
)
Run Code Online (Sandbox Code Playgroud)
所以我想我的问题是,我将如何解析基本文件名?
我有一些图像要旋转.我必须在图像旋转期间(由于插值)尽可能少地旋转它们(每个以不同的角度)旋转图像伪像(例如模糊).
目前我有GIMP 2.6,它具有可用于图像旋转的Cubic和Sinc(Lanczos3)插值.我不确定哪一个更好并且引入更少的文物?它有什么不利之处,如果有的话?
此外,还有一些其他软件(例如用于photoshop或gimp的插件)或Matlab的一些脚本可以提供近乎完美的图像旋转(例如,通过使用比GIMP中更好的插值算法)?
提前谢谢了.
想知道是否有一种简单的方法可以使用Gimp在图像的整个宽度上移除矩形切片,并自动关闭生成的孔.我希望这是有道理的.如果我在图像上选择切片并进行"切割",则会在那里留下一个空白的"孔".我希望图像的新顶部和底部能够连接并填充该孔,从而将图像高度减少一定量.
有什么简单的方法吗?
我刚刚开始学习使用Python编写Gimp脚本,并且想知道如何将文本输出到控制台?我在Windows 7上使用的是2.7.5版.
我尝试了print函数,但它没有向python-fu控制台或使用Gimp启动的开发控制台写任何东西.有没有我应该用来做这个功能?或者这是2.7.5版本的问题?我发现了一些"gimp-message",但这似乎与Scheme一起使用的函数(Script-fu)
谢谢!
(也在这里发布了一个帖子)
所以我尝试运行本教程中的批处理代码:http://www.gimp.org/tutorials/Basic_Batch/
我将其复制并保存到.gimp-2.8脚本文件夹中
(define (batch-unsharp-mask pattern
radius
amount
threshold)
(let* ((filelist (cadr (file-glob pattern 1))))
(while (not (null? filelist))
(let* ((filename (car filelist))
(image (car (gimp-file-load RUN-NONINTERACTIVE
filename filename)))
(drawable (car (gimp-image-get-active-layer image))))
(plug-in-unsharp-mask RUN-NONINTERACTIVE
image drawable radius amount threshold)
(gimp-file-save RUN-NONINTERACTIVE
image drawable filename filename)
(gimp-image-delete image))
(set! filelist (cdr filelist)))))
Run Code Online (Sandbox Code Playgroud)
然后运行命令:
gimp-2.8 -i -b '(batch-unsharp-mask "*.png" 5.0 0.5 0)' -b '(gimp-quit 0)'
Run Code Online (Sandbox Code Playgroud)
但我得到了错误
Error: ( : 1) eval: unbound variable: *.png
Run Code Online (Sandbox Code Playgroud)
这似乎不是脚本的问题; 可能是我称呼它的方式或我错过了一些东西,但我无法弄明白.
我正在尝试做GIMP在选择具有实际颜色的"颜色到alpha"时所做的事情.
我有一个颜色为#a0132e的图像,我想将其转换为透明度.不仅是那种确切的颜色,而且任何偏离它的颜色都必须变得非常透明.这就是GIMP中"颜色对alpha"的作用.
我已经尝试了一百万种不同的东西,但我无法理解它.我一直在为自己打扰几个小时尝试-fx
参数,这绝对是奇怪的语法,所以这根本没有帮助.也许有些选项convert
可以解决这个问题,但我还没有找到正确的做法,而且,我已经尝试了谷歌得到的所有东西.
理想情况下,我想创建一个我可以这样调用的脚本:
color-to-alpha.cmd original.png output.png #a0132e
或类似的.我怎样才能做到这一点?
我想我明白什么颜色配置文件.我不明白,操纵照片有什么不同,例如在photoshop中16bpp sRGB
和16bpp Adobe RGB
.我的显示器只能显示sRGB.
AdobeRGB(0.3, 0.25, 0.82)
显示sRGB(0.301, 0.253, 0.819)
在我的显示器中)?