我在使用gimp批处理模式时遇到了问题。我要做的就是打开2个png文件作为一个图像的图层,并将它们一起保存为图标(.ico)。
问题:Gimp只是将两个图像打开为单独的窗口,而不是一层中的两个图像。
我的代码如下所示:
(define (merge-to-icon filename layername endname)
(
let*
(
(image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image)))
(adlayer (car (gimp-file-load-layer RUN-NONINTERACTIVE image layername)))
)
(gimp-image-insert-layer image adlayer 0 0)
(set! drawable (car (gimp-image-get-active-layer image)))
(gimp-displays-flush)
(gimp-file-save RUN-NONINTERACTIVE image drawable endname endname)
))
答案 0 :(得分:4)
对于非交互模式:
class PagesController < ApplicationController
def action
head :ok
end
end
然后叫它:
(define (implode-imgs-save-ico fname-one fname-two)
(let* (
; first main image
(image (car (gimp-file-load RUN-NONINTERACTIVE fname-one fname-one)))
; them layer
(drawable1 (car (gimp-image-get-active-drawable image)))
; open image as layer
(drawable2 (car (gimp-file-load-layer RUN-NONINTERACTIVE image fname-two)))
)
; add layer to image
(gimp-image-insert-layer image drawable2 0 0)
;set layer mixing mode
(gimp-layer-set-mode drawable2 SCREEN-MODE)
; may be some resize here
; merge layers
(set! drawable (car (gimp-image-flatten image)))
; save
(file-ico-save RUN-NONINTERACTIVE image drawable "my.ico" "my.ico")
)
)