Intelligent trimming in Magick++
Hi,
I’m new to ImageMagick. I need a way to automatically trim images and have a few questions:
-I’ve found a MagickTrimImage function that allows intelligent trimming, is there any Magick++ equivalent (trim() takes no arguments)?
-if not, can I use Magick++ and MagickWand In the same program? (If so, how to compile such a hybrid)?
-is there a way to leave about 5% margin when trimming? (that is, not to trim all the background, but leave a minimum amount, so that it will look more natural)?
Thanks in advance for the answers.
Karol
Intelligent trimming in Magick++
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Intelligent trimming in Magick++
Generally you trim, and then re-add a border of the right color.carllos wrote:is there a way to leave about 5% margin when trimming? (that is, not to trim all the background, but leave a minimum amount, so that it will look more natural)?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Intelligent trimming in Magick++
Thanks for the answer, but that doesn't work for me. Usually the background has it's own texture - that's also why I can't use Image.trim(), so I can't just add a monocolor boarder.Generally you trim, and then re-add a border of the right color.
Let's say this is a the picture:
http://www.torun.mm.pl/~carllos_pl/im/213011527.jpg
This is what I get with MagickTrimImage (still haven't found aMagick++ equivalent):
http://www.torun.mm.pl/~carllos_pl/im/2 ... r_trim.jpg
And this is what I would want to get:
http://www.torun.mm.pl/~carllos_pl/im/2 ... 20want.jpg
Note: I do not want to lose the background (eg. by flood-filling it).
Karol
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Intelligent trimming in Magick++
Then do the trim but rather than output an image output the results of the trim.
You can then adjust those results and do the crop yourself.
Also see 'blured trim'....
http://www.imagemagick.org/Usage/crop/#trim_blur
You can then adjust those results and do the crop yourself.
Code: Select all
convert image -trim -format '%wx%h%O' info:
http://www.imagemagick.org/Usage/crop/#trim_blur
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Intelligent trimming in Magick++
Thank you very much this is what I was looking for,
Is there a Magick++ equivalent for this, or is it just accesible by the command line?
Is there a Magick++ equivalent for this, or is it just accesible by the command line?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Intelligent trimming in Magick++
You should be able to get that info directly from the trimmed image using 'get attributes'
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/