Page 1 of 1

Intelligent trimming in Magick++

Posted: 2007-07-11T15:16:15-07:00
by carllos
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

Re: Intelligent trimming in Magick++

Posted: 2007-07-11T19:14:21-07:00
by anthony
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)?
Generally you trim, and then re-add a border of the right color.

Re: Intelligent trimming in Magick++

Posted: 2007-07-12T01:51:39-07:00
by carllos
Generally you trim, and then re-add a border of the right color.
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.

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

Re: Intelligent trimming in Magick++

Posted: 2007-07-12T02:04:01-07:00
by anthony
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.

Code: Select all

convert image -trim -format '%wx%h%O' info:
Also see 'blured trim'....
http://www.imagemagick.org/Usage/crop/#trim_blur

Re: Intelligent trimming in Magick++

Posted: 2007-07-12T04:04:53-07:00
by carllos
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?

Re: Intelligent trimming in Magick++

Posted: 2007-07-12T19:55:14-07:00
by anthony
You should be able to get that info directly from the trimmed image using 'get attributes'