ImageMagick图片处理
ImageMagick
是一个用于查看、编辑位图文件以及进行图像格式转换的开放源代码软件套装。它可以读取、编辑超过100种图帧式。
命令格式
1 | 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 ,RLE orZip |
quality | 图片压缩质量,数值越高越清晰,JPEG/MIFF/PNG compression level. |
resize | 改变图片尺寸,Resize an image |
resize参数说明
size | General 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.) 分别指定缩放比例宽高 |
width | Width given, height automagically selected to preserve aspect ratio. |
xheight | Height given, width automagically selected to preserve aspect ratio. |
widthxheight | Maximum 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:y | Here x and y denotes an aspect ratio (e.g. 3:2 = 1.5). |
{size}{offset} | Specifying the offset (default is +0+0). Below, {size} refers to any of the forms above. |
{size}{+-}x{+-}y | Horizontal 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. |