giftrans インストール

透過GIFが作りたくなったので、giftrans を導入。

build

%  gcc -O3 giftrans_v1.12.3.c -o giftrans

install

% su
Password:
# ls /usr/lib/X11/.
# cp rgb.txt /usr/lib/X11/.
# cp giftrans /usr/local/bin/giftrans

usage

% giftrans
Usage: giftrans [-t color|-T] [-B color] [-b color] [-g oldcolor=newcolor] [-c comment|-C] [-l|-L|-V] [-o filename] [-e filename] [filename]
Convert any GIF file into a GIF89a, with the folloing changes possible:
-t Specify the transparent color
-T Index of the transparent color is the background color index
-B Specify the transparent color's new value
-b Specify the background color
-g Change a color in the global color table
-c Add a comment
-C Remove old comment
-l Only list the color table
-L Verbose output of GIFs contents
-V Verbose output while converting
-o Redirect stdout to a file
-e Redirect stderr to a file
Colors may be specified as index, as rgb.txt entry or in the #rrggbb form.

test

giftrans -t "#fcea33"  kuriboo.gif >  kuriboo-trans.gif

周りの黄色は微妙に統一されていなくて、透明になってるのは一部のみ。


todo

  • a オプションをつける
giftrans -a kuriboo.alpha  kuriboo.gif >  kuriboo-trans.gif

みたいな事がしたい。

と思ったら、昔作ってた。さすが自分…

元から透過GIFフォーマットのファイルに対して、
任意のピクセルを透明にするのと、256色全部使っている画像ではない。
という前提があって、いまいち。

でも、GIF は透明色を含めて256色なので、透明色無しで256色使う
GIFに透明色を追加しようとすると、透明以外の色を255色以内に収める
減色処理が必要になるので、ちょっと面倒。

まぁ、誰かに欲しいって言われたら頑張ろっと。