首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么在CLI模式下不使用GIMP脚本?

为什么在CLI模式下不使用GIMP脚本?
EN

Stack Overflow用户
提问于 2021-09-23 22:54:33
回答 1查看 85关注 0票数 0

我编写了一个GIMP脚本,如果我通过GIMP中的按钮打开它,它就会工作,但是如果我尝试以CLI模式(在Ubuntu上)启动它,它就不能工作。我尝试了以下命令:

代码语言:javascript
复制
 gimp -c -i -d -b '(documentEnhancementProcedure 1 "raw.png" "test.png")' -b '(gimp-quit 0)'

并获取错误:“参数2的无效类型到文件-png-load”.

因为脚本工作,所以当我从GIMP启动它时,我认为这是CLI命令的一个问题。

我试过:

全filepaths

  • escape字符

我认为这很可能是个小错误,但我目前还无法发现.

提前感谢您的帮助!

剧本:

代码语言:javascript
复制
(define (documentEnhancementProcedure infile outfile)
   (let*
        (
        (image (car (file-png-load 1 infile infile)))
        (drawable (car (gimp-image-get-active-drawable image)))

        (image-width (car (gimp-image-width image)))
        (image-height (car (gimp-image-height image)))

    )
    ;1. scale image by the factor 2
    (gimp-image-scale image
          (* image-width 2) (* image-height 2))
        ; (* image-width 2) New image width (1 <= new-width <= 524288)
        ;                   (* image-height 2) New image height (1 <= new-height <= 524288)


    ;2 apply sharpen-filter with given variables
    (plug-in-unsharp-mask 1 image drawable
          3 0.4 0)
        ; 3 Radius of gaussian blur (0 <= radius <= 300)
        ;   0.4 Strength of effect (0 <= amount <= 300)
        ;       0 Threshold (0 <= threshold <= 255)


    ;3.save image as png
    (file-png-save2 1 image drawable outfile outfile
          1 0 0 0 0 0 0 0 0 )
        ; 1 Adam7 interlacing?
        ;   0 deflate compression factor (0-9)
        ;     0 Write bKGD chunk?
        ;       0 Write gAMMA chunk?
        ;         0 Write oFFs chunk?
        ;           0 Write pHYS chunk?
        ;             0 Write tIME chunk?
        ;               0 Write comment?
        ;                 0 Preserve color of transparent pixels?

   )
)

(script-fu-register
    "documentEnhancementProcedure"                   ; script name to register
    "<Toolbox>/Xtns/Script-Fu/ownScripts/documentEnhancementProcedure" ; where it goes
    "document gets doubeld in size\
    and sharpened with following sharpen variables:\
    radius 3\
    amount 0.4\
    threshold 0"                                     ; script description
    ""                                               ; author
    "Copyright 2021 by; GNU GPLv3"                   ; copyright
    "23.09.2021"                                     ; date
    ""                                               ; type of image
    SF-FILENAME "Infile" "infile.png"                ; default parameters
    SF-FILENAME "Outfile" "outfile.png"
)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-11-04 13:14:34

The comment by @xenoid worked:

尝试省略RUN-MODE参数。顺便说一句,如果在批处理模式中使用脚本,则不需要注册脚本;2)可以使用ImageMagick的convert命令(参见-geometry-sharpen args)在一行中完成相同的操作。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69307734

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档