如何使用GIMP中的Script-FU从所有文件夹中获取文件列表(*.jpg)?
(let* ((filelist (cadr (file-glob pattern 1)))
Run Code Online (Sandbox Code Playgroud)
这只从当前文件夹中获取文件.
我经常扫描手写文档发送给同事,并且需要在扫描后对数字文件进行更正.(例如,我将原始文档上的错误更改为白色.)
我在考虑一些可以执行以下操作的脚本:
将彩色扫描图像(比如tiff)作为输入,并根据图像中的彩色校正自动进行简单校正.
例如,最简单的情况是:我只在白色上写黑色.有一个区域我犯了错误,所以我在该区域周围绘制了一个红色的闭合圆圈(在实际纸张上用笔).然后我扫描图像(或通常很多).现在我希望脚本擦除所有图像中的每个区域,这样我的错误就会在结果图像中消失.
任何想法如何在Linux环境中实现这一点,例如使用Image Magick?
它看起来像Gimp with script-fu可能是它应该足够强大的方式.有人可以通过指出上面的例子看起来像在script-fu中给我一个提示吗?
例如,我生成了一些高分辨率的出版质量图
library(plot3D)
Volcano<-volcano
zf=10 #zoom factor
tiff("Volcano.tif", width=1800*zf, height=900*zf, res=175*zf, compression="lzw")
image2D(z = Volcano, clab = "height, m",colkey = list(dist = -0.20, shift = 0.15,side = 3, length = 0.5, width = 0.5,cex.clab = 1.2, col.clab = "white", line.clab = 2,col.axis = "white", col.ticks = "white", cex.axis = 0.8))
dev.off()
Run Code Online (Sandbox Code Playgroud)
该文件是22 MB.
现在我用GIMP打开文件而不做任何其他事情我将它导出为"Volcano gimp.tif"(不要改变分辨率,或做任何其他事情).GIMP生成一个1.9 MB的文件("Volcano gimp.tif").
imagemagick 报告相似图片统计:
$ identify Volcano.tif
Volcano.tif TIFF 18000x9000 18000x9000+0+0 8-bit DirectClass 22.37MB 0.000u 0:00.000
$ identify "Volcano gimp.tif"
Volcano gimp.tif TIFF 18000x9000 …Run Code Online (Sandbox Code Playgroud) 我正在更改GIMP中的网格配置(首选项 - >默认网格).我将间距从原来的10 px增加到40px,并且偏移量也增加了(从0到10 px).但是图像中的网格外观保持不变 - 仍然是10 x 10 px单元格,没有偏移,好像我没有做任何配置.
我能错过什么?
GIMP 2.8.10,Windows 7 64位.
我是gimp python-fu编程的新手我已经花了4天没有运气来弄清楚哪个是最合适的函数来获取绘制路径的坐标并在gtk消息框上显示输出,如下图所示.
请考虑我在Windows机器上开发
我尝试过这样的代码:
import gtk, gimpui
from gimpfu import *
def debugMessage(Message):
dialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, Message)
dialog.run()
dialog.hide()
def python_fu_mahdicoordinates(image, layer):
vectors = pdb.gimp_image_get_active_vectors(image)
nstrokes, strokes = pdb.gimp_vectors_get_strokes(vectors)
stroke_type, n_points, cpoints, closed = pdb.gimp_vectors_stroke_get_points(vectors, strokes[0])
x0 = cpoints[0]
y0 = cpoints[1]
x1 = cpoints[6]
y1 = cpoints[7]
x2 = cpoints[12]
y2 = cpoints[13]
x3 = cpoints[18]
y3 = cpoints[19]
debugMessage('(' + str(x0) + ', ' + str(y0) + ', '+str(x1) + ', '+str(y1) + ', '+str(x2) …Run Code Online (Sandbox Code Playgroud) 我能找到的唯一函数是:gimp-color-balance,它采用适用的参数:preserve-lum(osity)、青色-红色、品红色-绿色和黄色-蓝色。
我不确定要为这些参数传递什么值以复制标题中的菜单选项。
这是一个相当广泛的问题,所以我会尽力集中精力。
我目前拥有一台安装了 Ubuntu 并具有触摸屏功能的联想笔记本电脑,还有一支压敏蓝牙笔,并一直在尝试让两者一起工作,作为一款廉价的类似 Cintiq 的平板电脑。
不幸的是,这款笔仅支持 iOS 手机和平板电脑的特定应用程序。
因此,经过大量研究,我成功地与笔连接并uinput为其创建了一个设备,这样我就可以记录笔上的按钮点击和压力变化,甚至可以在通过“输入控制器”菜单配置设备时看到它们路由到 GIMP 。
到目前为止,我拥有的该接口的代码可以在这里找到。
当尝试用 GIMP 测试它时,麻烦就开始了。
据我所知,这是因为 GIMP 假设 Wacom 设备报告自己的位置,将触摸屏触摸视为鼠标移动,并且一次只允许来自单个设备的输入。
我的问题是,我该如何解决这个问题?
更具体地说,我如何创建一个uinput充当 Wacom 平板电脑并取代/阻止我描述的行为的设备?
或者是否有不同的解决方案,例如修补 GIMP 或为其编写插件。
上面提到的代码现在可以工作了。
我写了一篇关于让它发挥作用的过程的博客文章:http://gerev.github.io/laptop-cintiq
在 Windows 环境中,我想调用 GIMP 来执行 python-fu 脚本(通过 BAT 文件),但是我使用的命令行调用没有产生预期的结果。
例如,考虑以下名为 的 python-fu 脚本makeafile_and_quit.py,它位于我的 GIMPplug-ins文件夹中。其目的是加载现有图像并以不同名称保存:
#!/usr/bin/env python
# Sample call from GIMP's python-fu console:
# pdb.python_fu_makeafile_and_quit_script()
from gimpfu import *
def makeafile_and_quit( ) :
FILEPATH = 'C:\\path\\to\\file.JPG'
IMAGE = pdb.gimp_file_load( FILEPATH, FILEPATH )
pdb.gimp_file_save( IMAGE, pdb.gimp_image_get_active_drawable( IMAGE ), FILEPATH + '_2.jpg', FILEPATH + '_2.jpg' )
pdb.gimp_quit(0)
return
# PLUGIN REGISTRATION
# This is the plugin registration function
register(
'makeafile_and_quit_script',
'v0.0',
'A new concept',
'Author',
'Author',
'Just now', …Run Code Online (Sandbox Code Playgroud) 我想调整目录中每个 jpg 的大小。
这是我找到的 gimp 脚本。对我来说看起来很明智。
(define (batch-resize pattern)
(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-active-drawable image)))
(cur-width (car (gimp-image-width image)))
(cur-height (car (gimp-image-height image)))
(width (* 0.25 cur-width))
(height (* 0.25 cur-height))
)
(gimp-message filename)
(gimp-image-scale-full image width height INTERPOLATION-CUBIC)
(let
((nfilename (string-append "thumb_" filename)))
(gimp-file-save RUN-NONINTERACTIVE image drawable nfilename nfilename)
)
(gimp-image-delete image)
)
(set! filelist (cdr filelist))
)
)
) …Run Code Online (Sandbox Code Playgroud) 我最近从 2.8 更新到 2.10 GIMP,似乎导入自定义(相对)*.py 文件的插件都不再工作了。我剖析了代码,它不是“path_tools.py”文件的内容,它只是尝试导入自定义模块的行为(即使它是一个空文件,它仍然无法工作)。如果没有这行代码,它就可以在 GIMP 中正常显示:
from path_tools import *
Run Code Online (Sandbox Code Playgroud)
插件和path_tools.py都在同一个文件夹中
\AppData\Roaming\GIMP\2.10\plug-ins
我尝试通过添加句点来使用显式相对
from .path_tools import *
from ..path_tools import *
from ...path_tools import *
etc.
Run Code Online (Sandbox Code Playgroud)
我尝试通过在文件底部添加一个空的 GIMP 效果来将文件变成插件,看看 GIMP 是否只是以某种方式忽略了我的文件
def path_tools(img, drw):
return
register(
"python-fu-path-tools",
"Path Tools",
"",
[...]
Run Code Online (Sandbox Code Playgroud)
并通过在命令提示符中打开 GIMP
"c:\program files\gimp 2\bin\gimp-2.10" --verbose --console-messages
Run Code Online (Sandbox Code Playgroud)
它只是为每个无法加载的插件提供了一堆此类消息:
Querying plug-in: 'C:\Users\ \AppData\Roaming\GIMP\2.10\plug-ins\path_tools.py'
c:\program files\gimp 2\bin\gimp-2.10: LibGimpBase-WARNING: gimp-2.10: gimp_wire_read(): error
Run Code Online (Sandbox Code Playgroud)
但这些看起来像是警告,特别是因为另一个无法加载的插件存在实际错误,出于类似的原因我猜测:
GIMP-Error: Unable to run plug-in "export-ALL.py"
Run Code Online (Sandbox Code Playgroud)
与顶部的这些警告有关吗?
Parsing 'c:\program files\gimp 2\lib\gimp\2.0\interpreters\pygimp.interp'
GIMP-Warning: Bad interpreter referenced in interpreter …Run Code Online (Sandbox Code Playgroud)