Skip to content
ImageMagick图片处理

命令格式

bash
convert -auto-orient -strip -compress JPEG2000 -quality 50 -resize 50% 1.jpg 2.jpg

常用参数说明

参数功能
auto-orient根据图片旋转方向自动扶正,adjusts an image so that its orientation is suitable for viewing (i.e. top-left orientation).
strip清除图片档案信息,如EXIF,strip the image of any profiles, comments or these PNG chunks: bKGD,cHRM,EXIF,gAMA,iCCP,iTXt,sRGB,tEXt,zCCP,zTXt,date
compress指定图片压缩格式,Use pixel compression specified by type when writing the image.Choices are:None,BZip,Fax,Group4,JPEG,JPEG2000,Lossless,LZW,RLEorZip
quality图片压缩质量,数值越高越清晰,JPEG/MIFF/PNG compression level.
resize改变图片尺寸,Resize an image

resize参数说明

sizeGeneral description (actual behavior can vary for different options and settings)
scale%Height and width both scaled by specified percentage.
宽高等比例缩放
scale-x%xscale-y%Height and width individually scaled by specified percentages. (Only one % symbol needed.)
分别指定缩放比例宽高
widthWidth given, height automagically selected to preserve aspect ratio.
xheightHeight given, width automagically selected to preserve aspect ratio.
widthxheightMaximum values of height and width given, aspect ratio preserved.
widthxheight^Minimum values of width and height given, aspect ratio preserved.
widthxheight!Width and height emphatically given, original aspect ratio ignored.
widthxheight>Shrinks an image with dimension(s) larger than the corresponding width and/or height argument(s).
widthxheight<Enlarges an image with dimension(s) smaller than the corresponding width and/or height argument(s).
area@Resize image to have specified area in pixels. Aspect ratio is preserved.
x:yHere x and y denotes an aspect ratio (e.g. 3:2 = 1.5).
{size}Specifying the offset (default is +0+0). Below, {size} refers to any of the forms above.
{size}{+-}x{+-}yHorizontal and vertical offsets x and y, specified in pixels. Signs are required for both. Offsets are affected by ‑gravity setting. Offsets are not affected by % or other size operators.

Updated at: