自动化 Gimp 插件镜头失真校正

自动化 Gimp 插件镜头失真校正

我执行了镜头失真滤镜,对其进行了调整,直到我获得了可以补偿广角镜头的设置。我想自动执行此操作,以便我可以从命令行执行校正。

plug-in-lens-distortion 的文档与 gui 参数一致,但我不知道如何通过批处理宏或脚本自动执行此操作。我希望有一个简单的示例,说明如何将这种镜头失真应用于图像并将其保存回新文件名。

答案1

如果这仍然是一个要求,请尝试以下操作:

  (let* 
    (
      (destination_file "")
      (varFileList (cadr (file-glob (string-append "*" file_extension) 1))) ; make a list of all the files that match the file extension

      ; Adjust these values to suit     
    )
    (gimp-message-set-handler ERROR-CONSOLE)
    (if (not (file-exists? destination_directory))
      (error (string-append "Error: directory " destination_directory " doesn't exist"))
      (if (= (file-type destination_directory) FILE-TYPE-DIR)
        ()
        (error (string-append destination_directory " is not a directory"))
      )
    )

    ; loop through all the files in the list
    (for-each
      (lambda (filename)
        (let* (
               (image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))  ; load the image
               (drawable (car (gimp-image-flatten image)))

               (offset-x 0)
               (offset-y 0)
               (main-adjust 100.0)
               (edge-adjust 100.0)
               (rescale -25.48)
               (brighten 31.46)
              )
              (gimp-message (string-append "processing-" filename))

              (plug-in-lens-distortion RUN-NONINTERACTIVE image drawable offset-x offset-y main-adjust edge-adjust rescale brighten)

              (set! destination_file (string-append destination_directory DIR-SEPARATOR filename))
              (gimp-file-save RUN-NONINTERACTIVE image drawable destination_file destination_file)
              (gimp-image-delete image)                  ; unload the image           
        )
      )
      varFileList
    )
  )
)

Windows 上的命令行:

"C:\Program Files\GIMP 2.10\bin\gimp-2.10.exe" -i -f -d --verbose -b "(batch_lens_distort \".jpg\" \"destination\")" -b "(gimp-quit 0)"

您需要在其中创建一个名为目标的目录,用于存放修改后的图像。

相关内容