ImageMagic检测图像是否有边框或框架 [英] ImageMagic detect if the image has border or frame
问题描述
基本上,我的图像周围有一个黄色的粗边框,类似于NetGeo图像.我想检查是否有边框(NetGeo只是一个例子,边框颜色可以是任何宽度和任何颜色),我想检测出该边框并将其剃光(如果存在).>
我看到此问题已在
但是如果没有实线边框,我不想裁剪图像.
例如
我不想删除黄色,因为它不是实线边框.希望它有助于理解这个问题.
此代码似乎可以在ImageMagick中使用
转换NG.png-模糊20%-背景"rgb(239,204,60)"-定义修剪:背景百分比= 0%-修剪+ repage x.png
Basically, I have a image with a thick yellow border around it something like NetGeo image. I want to check if there is border or not (NetGeo is just an example, border color can be of any width and any color), I want to detect that and shave it if it exists.
I see this question is been answered in Trim whitespace using PIL for PIL but I am looking for same solution in imagemagick with a single command or java
But I don't want to crop the image if there is not solid border.
For example
I don't want to remove the yellow color as it is not a solid lined border. Hope it helps to understand the question.
This code seems to work in ImageMagick
convert NG.png -fuzz 20% -background "rgb(239,204,60)" -define trim:percent-background=0% -trim +repage x.png
这篇关于ImageMagic检测图像是否有边框或框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!