- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2020-05-27T12:18:14+09:00","","")
#author("2020-05-27T20:00:37+09:00","","")
* 画像ファイルの扱い [#g02ad308]
[[ビデオファイルの扱いメモ>movie_files]] にも関連情報(主に ffmpeg )あり
------
#contents
** imagemagick でサイズ変更 2020年5月25日 [#gb65a218]
アスペクト比を変えずに変更
$ convert ifile.png -resize 640x ofile.png ← 幅を指定
$ convert ifile.png -resize x540 ofile.png ← 高さを指定
$ convert ifile.png -geometry 30% ofile.png
参考:https://imagemagick.biz/archives/93
** imagemagick でトリミング(切り抜き) [#f826400e]
*** 単にトリミングするとき 2020年5月25日 [#uc0f5ca3]
$ convert ifile.png -crop 1920x1080+243+94 ofile.png ← (width) x (height) +(x) + (y)
ペイントなどを利用して、どういう風に切るかの数字を見付ける
参考:https://imagemagick.biz/archives/550
trim オプションを使うと、周辺の単一色(または無色)の部分を削り取るので注意
$ convert ifile.png trim ofile.png
*** トリミングした画像ファイルを別途利用するとき 2020年5月25日 [#a09a3f14]
convert だけだとレイヤーが残る = キャンバスサイズが大きなままになる~
キャンバスサイズやどのようにトリミングが行われたかなどは、identify で確認できる~
$ identify trimmed.png
trimmed.png PNG 1500x925 1920x1080+243+94 8-bit sRGB 47909B 0.000u 0:00.000
これのような、キャンバスサイズが元のままで、再度 crop しようとするとヘンになる。~
それを避けるためには、mogrify +repage をする。
$ mogrify +repage trimmed.png
$ identify trimmed.png
trimmed.png PNG 1500x925 1500x925+0+0 8-bit sRGB 47881B 0.000u 0:00.001
キャンバスサイズがトリミングした大きさに一致していることが、identify で確認できる
参考:https://qiita.com/yoya/items/62879e6e03d5a70eed09
** コントラスト調整 2020年5月27日 [#a63def88]
$ convert ifile.png -normalize ofilen.png
$ convert ifile.png -linear-stretch 0x0.0001% ofilel.png
-normalize ← to -contrast-stretch 2%x1% と同じ
-linear-stretch 0x0.0001%
どちらもコントラストを強める補正~
オプションの -linear-stretch と -contrast-stretch は
よく似ているが、-linear-stretch は
the image colors are stretched mathematically で、
一方、-contrast-stretch は using the histogram bins との違いがある。
どっちが美しいのかよくわからないけれど、histogram bins を
使ってしまうと、結果的にガンマを触っていることになりそうなので、
ぼくらの仕事の分野ではよくないような気がする。~
似たもので -auto-level があるが、これは real-life images
には使わない(使えない)。外れ値があった場合、もろに影響されてしまうため。
※ -contrast-stretch の説明では、 -normalize は -contrast-stretch
0.15x0.05% と同じと書いてあり、矛盾がある
参考:~
https://qiita.com/yoya/items/1da8e8e04881bab67015~
https://imagemagick.org/script/command-line-options.php~
** ヒストグラム生成 2020年5月27日 [#ze908c8a]
$ convert ifile.png histogram:histo-ifile.png ← カラー
$ convert histo-ifile.png -strip -separate histo-%d.png ← 3色分解したもの
$ convert ifile.png histogram:- | identify -format %c - ← 分布の数値がほしいとき
photoshop の作るヒストグラムと違いがないようです。
平均値など、まとめの数値がほしいときは、identify を使うしかなさそう。
沢山データが吐き出される(喜べ!)。
$ identify -verbose ifile.png
参考:~
https://www.imagemagick.org/Usage/files/~
http://kyle-in-jp.blogspot.com/2008/02/imagemagick_26.html
|Today:&counter(today); |Yesterday:&counter(yesterday); |Total:&counter(); since 25 May 2020|