ImageMagick使用笔记

系统管理自动化、图像处理(ImageMagick, WebP, nConvert)、文档转换(pandoc)、网络(wget, curl)
头像
paktc
渐入佳境
渐入佳境
帖子: 52
注册时间: 2016年07月21日 20:34
拥有现金: 锁定
储蓄: 锁定
Has thanked: 6 times
Been thanked: 5 times
联系:

ImageMagick使用笔记

帖子 #1 paktc » 2018年10月27日 10:51

1楼站位 + 索引

头像
paktc
渐入佳境
渐入佳境
帖子: 52
注册时间: 2016年07月21日 20:34
拥有现金: 锁定
储蓄: 锁定
Has thanked: 6 times
Been thanked: 5 times
联系:

Re: ImageMagick使用笔记

帖子 #2 paktc » 2018年10月27日 10:52

自动裁剪图片周边的空白部分 -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".


回到 “第三方命令行工具”

在线用户

用户浏览此论坛: 没有注册用户 和 1 访客