Skip to content

Instantly share code, notes, and snippets.

@wongyouth
Last active June 28, 2017 01:33
Show Gist options
  • Save wongyouth/ee175e1413de482666f2246601853b0c to your computer and use it in GitHub Desktop.
Save wongyouth/ee175e1413de482666f2246601853b0c to your computer and use it in GitHub Desktop.

Geometry 释义

logo.png 640x480

convert logo: -resize '200%' bigWiz.png                     => 1280x960
convert logo: -resize '200x50%' longShortWiz.png            => 1280x240
convert logo: -resize '100x200' notThinWiz.png              => 100x72
convert logo: -resize '100x200^' biggerNotThinWiz.png       => 267x200
convert logo: -resize '100x200!' dochThinWiz.png            => 100x200

convert logo: -resize '100' wiz1.png                        => 100x72
convert logo: -resize 'x200' wiz2.png                       => 267x200
convert logo: -resize '100x200>' wiz3.png                   => 100x72  只有值大时缩小
convert logo: -resize '100x200<' wiz4.png                   => 640x480 只有值小时放大

生成指定大小的白底图片

convert -size 1308x1328 xc:white 1308x1328.jpg

切分图片

8x8 分割文件

convert -crop 12.5%x12.5% +repage input.jpg out-%02d.jpg

合并回来

mongtage out-*.jpg -geometry +0+0 -tile 8x8 out.png

Progressive image

convert -strip -interlace Plane input.jpg out.jpg

切割文件 从左上角起始100x100大小

convert largefile[100x100+0+0] +repage 100.png

crop 文件,与上面处理类似,但是性能稍差

convert logo: -crop 480x240+0+0 +repage logo.jpg

tile

convert -size 200x200 radial-gradient:red-blue t200x200.png
convert -size 1200x800 tile:t200x200.png BigBoy.png

sample

http://www.imagemagick.org/discourse-server/viewtopic.php?t=22860

width=1056
height=576
infile="Castillo_001_crop2.gif"
hh2=`convert $infile -format "%[fx:h/2]" info:`
convert $infile \
\( -clone 0 -roll +0+${hh2} \) +append \
-write mpr:cell +delete \
-size ${width}x${height} tile:mpr:cell \
Castillo_001_tiles.gif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment