Limit trim to one direction

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
btnadiga

Limit trim to one direction

Post by btnadiga »

Using the command line, how would I trim (-trim) an image only say in x direction
Thanks a bunch,
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Limit trim to one direction

Post by fmw42 »

btnadiga wrote:Using the command line, how would I trim (-trim) an image only say in x direction
Thanks a bunch,
I don't think -trim allows directional control. The only way I can think of doing that is to use -extent to add a few pixels of different color on the two sides you want to preserve, then use -extend to add a few pixels of the same color on the side you want to trim so that the corner pixels are the color you want to trim, but the most of the other two sides are not that color. Then use -trim to remove the color you want on the one side and then follow that with -shave to remove the added other color on the other side.

The simplest way is just to measure and use -crop ... +repage
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Limit trim to one direction

Post by anthony »

See IM Examples... One sided Trim...
http://www.imagemagick.org/Usage/crop/#trim_oneside
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
btnadiga

Re: Limit trim to one direction

Post by btnadiga »

The problem is that I have a sequence of images where the object of interest moves. So manual cropping is not viable.

Actually, xv -acrop works great (except that I could not figure out how to make it save the cropped images without using the gui)

So, if one of you can tell me the optional parameters for Imagemagick that will emulate xv -acrop it would be perfect.

Thanks,
Balu
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Limit trim to one direction

Post by fmw42 »

btnadiga wrote:The problem is that I have a sequence of images where the object of interest moves. So manual cropping is not viable.

Actually, xv -acrop works great (except that I could not figure out how to make it save the cropped images without using the gui)

So, if one of you can tell me the optional parameters for Imagemagick that will emulate xv -acrop it would be perfect.

Thanks,
Balu

I don't believe there is one. See the two posts above as to how you have to script it.

or

trim all around and then pad back on the sides you want using -extent
Post Reply