2005年9月 3日

ImageMagick。

今日も洗濯の後、本屋で立ち読み。

あれー?Software Design 9月号がない。
おまけに、PHP関係の本もない。
一体どうしたんだ?

なにはともあれ、今日も帰宅するとお勉強。
ポスグレちゃんと遊ぶのは、ちょっと勘弁してもらい
それより急いで再確認しておきたい、ImageMagickについて。

ImageMagick を使うと、画像をちょっとばかし加工出来たりする訳ですが、
今回やりたいのは、複数の画像の合成。

で、Javaで扱うためにJMagickなるものがあるとゆーので、
早速いじってみるも、なんか…合成は出来ないのかしらん???

って訳で、てっとり早く、素直なやり方でImageMagickを使う事に。


Runtime.getRuntime().exec("convert -composite inputFile1.png inputFile2.png outputFile.png");

…で、これで本当は合成できるはずなんだけど、
例によってcoLinuxに
「apt-get install imagemagick」でインストールしたImageMagick は、
何故かバージョンが古かった…。

そして、上記を実行してみると、
「composite なんて引数は、ありゃしないよ~」と言われる始末。
う"ーん"。バージョンのせいなのか???

ちなみに、Windows版のImageMagickの最新版
ImageMagick-6.2.4-3-Q16-windows-dll.exe
をインストールしてみたら、
こっちにはちゃんとcompositeが使えて、
コマンドプロンプト上では、あっさり成功。

ただし、何故かJavaから制御しようとすると、
imdisplayなんかは実行出来ても、
convert系のもので、何かファイルを書き出そうと
エラーは表示されないけど、失敗してました。

試しに cygwin で書き出し先のフォルダのパーミッションを
思いっきり 777 とかにもしてみたけど、それでもダメ。
うーん、どうしたらいいんだか。

なにはともあれ、本番はWindowsじゃないんで、
まぁ、なんとかなるっしょ(?)ー。

ちなみに、coLinux上に入れた、バージョン6.0.6で実行可能だった
convert -compose で、いろんな加工してファイルをはいてみた結果、
期待する合成結果になったのは、下記の通り。

もとの画像・その1 test1.png
もとの画像・その2 test2.png
もとの画像・その3 test3.png


実行コマンド結果
convert -compose src-over test1.png test2.png test.png
convert -compose src-over test.png test3.png test.png

他にも、いろんな加工してみたんで、表にして書き出しておきますね。
画像付きだから、重くてごめん。


実行コマンド結果
convert -compose clear test1.png test2.png test_clear.png
convert -compose src test1.png test2.png test_src.png
convert -compose src-over test1.png test2.png test_src-over.png
convert -compose src-in test1.png test2.png test_src-in.png
convert -compose src-out test1.png test2.png test_src-out.png
convert -compose src-atop test1.png test2.png test_src-atop.png
convert -compose dst-atop test1.png test2.png test_dst-atop.png
convert -compose dst-out test1.png test2.png test_dst-out.png
convert -compose dst-in test1.png test2.png test_dst-in.png
convert -compose dst-over test1.png test2.png test_dst-over.png
convert -compose dst test1.png test2.png test_dst.png
convert -compose xor test1.png test2.png test_xor.png
convert -compose plus test1.png test2.png test_plus.png
convert -compose multiply test1.png test2.png test_multiply.png
convert -compose screen test1.png test2.png test_screen.png
convert -compose overlay test1.png test2.png test_overlay.png
convert -compose darken test1.png test2.png test_darken.png
convert -compose lighten test1.png test2.png test_lighten.png
convert -compose color-dodge test1.png test2.png test_color-dodge.png
convert -compose color-burn test1.png test2.png test_color-burn.png
convert -compose hard-light test1.png test2.png test_hard-light.png
convert -compose soft-light test1.png test2.png test_soft-light.png
convert -compose difference test1.png test2.png test_difference.png
convert -compose exclusion test1.png test2.png test_exclusion.png

Posted by anigon at 10:27 PM

「簡易英独辞書。」へ戻る | 「イベリコさん。」へ進む

上へ戻る