LoginSignup
1
1

More than 5 years have passed since last update.

ImageMagick > 画像をアスペクト比を保たずに任意のサイズに変換する > mogrify green.png -resize 100x20! green_exp.png

Last updated at Posted at 2017-10-04
動作環境
Xeon E5-2620 v4 (8コア) x 2
32GB RAM
CentOS 6.8 (64bit)
openmpi-1.8.x86_64 とその-devel
mpich.x86_64 3.1-5.el6とその-devel
gcc version 4.4.7 (とgfortran)
NCAR Command Language Version 6.3.0
WRF v3.7.1を使用。
Python 2.6.6 (r266:84292, Aug 18 2016, 15:13:37) 
Python 3.6.0 on virtualenv
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)

希望

20x20のサイズの画像を100x20のサイズに伸ばす。

方法

参考: https://stackoverflow.com/questions/20438898/resize-image-with-mogrify-without-keeping-aspect-ratio

mogrifyというコマンドがImageMagickにはあるようだ。

mogrify input.png -resize 256x256! output.png

サイズの後ろに「!」をつけることで、アスペクト比を保たずに変換ができるようだ。

試してみた

サンプル画像を作成

$convert -size 20x20 xc:green green.png

コマンドを実行
(ただし、出力ファイルがすでにないとエラーになる。コピーしてから実行?)

$mogrify green.png -resize 100x20! green_exp.png 

横方向に伸びた画像が生成された。

サイズ確認

$ identify green.png 
green.png PNG 20x20 20x20+0+0 8-bit PseudoClass 1c 203B 0.000u 0:00.000
$ identify green_exp.png 
green_exp.png PNG 100x20 100x20+0+0 8-bit PseudoClass 1c 204B 0.000u 0:00.000

関連: ImageMagick > 画像ファイルの情報を見る > identify test.bmp

コマンド名identifyを忘れてしまう。

関連

jsFiddle + Google Maps > 指定の緯度経度範囲(四角)をマーキングで表示 v0.1

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1