忍者ブログ
  • 2024.03«
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • » 2024.05
[PR]
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

【2024/04/27 00:27 】 |
icon2png(改)
icon2pngを改良してみた。
インデックスカラーを指定した場合、gimpはiconの構成をレイヤーに落とすため
すべて同じパレットを指定してしまう不具合。

例えばレイヤー1が赤1色、レイヤー2が白一色の場合
インデックスカラー1色とすれば、赤と白で画像が2つ出きるはずが
ピンク色で2つできてしまう。

なお、インデックスカラーを決定するのはRGB→インデックスとしたタイミングのみで
レイヤーを後から追加してもインデックスカラーは再計算されない。
このためRGBに戻して追加した後にインデックスカラーにする必要があった。

~/.gimp-2.6/scripts/icon2png.scm

(define (convert-layer-file imagenew colors image filename tattoos idx)
(let*
(
(drawable (car (gimp-image-get-layer-by-tattoo image (aref tattoos idx))))
(fn (string-append filename (number->string idx) ".png"))
(drawablenew (car (gimp-layer-new-from-drawable drawable imagenew)))
)
(print idx)
(print fn)
(gimp-image-add-layer imagenew drawablenew 0)

(if (> colors 0)
(gimp-convert-indexed imagenew NO-DITHER MAKE-PALETTE colors TRUE FALSE "")
)

(file-png-save RUN-NONINTERACTIVE
imagenew
drawablenew
fn
""
0
9
0
0
0
0
0
)

(gimp-image-remove-layer imagenew drawablenew)

(if (> colors 0)
(gimp-convert-rgb imagenew)
)

(if (> idx 0)
(convert-layer-file imagenew colors image filename tattoos (- idx 1))
)
)
)

(define (icon2png filename colors)
(let*
(
(image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(tatooarr (gimp-image-get-layers image))
(imagenew (car (gimp-image-new (car (gimp-image-width image)) (car (gimp-image-height image)) RGB)))
)
;(gimp-display-new image)
(convert-layer-file imagenew colors image filename (cadr tatooarr) (- (car tatooarr) 1))
(gimp-image-delete image)
(gimp-image-delete imagenew)
)
)



コマンド

gimp -i -b '(icon2png "t.ico" 2)' -b '(gimp-quit 0)'

拍手[0回]

PR
【2012/11/25 09:24 】 | gimp | 有り難いご意見(0)
<<cout vs printf | ホーム | icon2png>>
有り難いご意見
貴重なご意見の投稿















前ページ | ホーム | 次ページ

忍者ブログ [PR]