我希望用戶繪製一些東西。我將多次旋轉該圖像,並將每個文件保存到一個文件夾中。模板是img<degree>.png
,例如img24.png
是旋轉24度的原始圖像。這就像使用Rotate tool
,將其設置爲24度並使用默認座標導出它。重複旋轉 - 在導出到PNG時增加圖像尺寸
問題是,我每次旋轉並導出到PNG文件越來越大。當原始文件是100x100 & 380B時,第9個文件是413x412 2,47KB。我希望圖像保持相同的大小(在上例中爲100x100)。
(define (degrees-to-radians degrees) (/ (* degrees *pi*) 180))
(define (script-fu-rotate-and-save in-image in-drawable directory-name) ; degree)
(let ((ind 0) (x 0) (y 0))
(while (< ind 361)
(set! x (car (gimp-image-width in-image)))
(set! y (car (gimp-image-height in-image)))
(gimp-item-transform-rotate in-drawable (degrees-to-radians ind) FALSE (/ x 2) (/ y 2))
(file-png-save-defaults 1 in-image in-drawable (string-append directory-name "/img" (number->string ind) ".png") (string-append directory-name "/temp.png"))
(set! ind (+ ind 45))
)
)
;(gimp-displays-flush) ; show changes on image
)
(script-fu-register
"script-fu-rotate-and-save" ;name
"rotate and save"
"Rotates and saves"
"me"
"copyrights"
"today"
""
SF-IMAGE "image-main" 0
SF-DRAWABLE "drawable-main" 0
SF-DIRNAME "directory-name" ""
;SF-ADJUSTMENT "label" '(value lower upper step_inc page_inc digits type)
;SF-ADJUSTMENT "degree" '(1 1 360 1 1 0 0)
)
(script-fu-menu-register "script-fu-rotate-and-save" "<Image>/Rotate and save")