ImageMagick使用笔记

系统管理自动化、图像处理(ImageMagick, WebP, nConvert)、文档转换(pandoc)、网络(wget, curl)
回复
头像
paktc
出类拔萃
出类拔萃
帖子: 65
注册时间: 2016年07月21日 20:34
联系:

ImageMagick使用笔记

帖子 paktc »

1楼站位 + 索引
头像
paktc
出类拔萃
出类拔萃
帖子: 65
注册时间: 2016年07月21日 20:34
联系:

Re: ImageMagick使用笔记

帖子 paktc »

自动裁剪图片周边的空白部分 -trim 参数

但是如果主体的边缘有暗影,怎么做呢?

http://www.imagemagick.org/Usage/crop/#trim
Trimming with fuzzy color selection -- Low Quality JPEG Images
Because JPEG is 'lossy' the colors in the image is generally not a single color but slightly varying band of different colors. because of this "-trim" will often fail for JPEG or real world images.

FUTURE: Example of failure here

As such you need to tell ImageMagick that colors that are not-exactly the same, but are reasonally close should be treated as being the same. Adding a very small "-fuzz" setting will do this.


convert image.jpg -fuzz 1% -trim +repage image_fuzzy_trim.jpg

It is also a very good idea to specify the specific color you want that fuzz to be relative to. This can be added by specifically added a border of that color using the "-border" operator. The border will of course always match the color to be trimmed, so will always be removed by "-trim".
回复

在线用户

正浏览此版面之用户: 没有注册用户 和 0 访客