Trim Bounding Box Center

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
checksumfail
Posts: 1
Joined: 2015-06-09T07:29:36-07:00
Authentication code: 6789

Trim Bounding Box Center

Post by checksumfail »

The command:

Code: Select all

convert image.jpg -fuzz 50% -format "%@" info:
Gives you the details of how many pixels would be trimmed horizontally and vertically if you were to use trim, this is great as it allows you to do modify these numbers to do a trim that leaves a slight border.

However, It doesn't give you the center of this bounding box, it gives the new image size, the total of the horizontal/vertical pixels that would be trimmed away but not how much on the left vs on the right etc.

Is it possible to also get the co-ordinates of the center of the trim box?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Trim Bounding Box Center

Post by snibgo »

-format "%@" gives the new width and height, and coords of top-left corner. This is as required for the "-crop" operation. For the centre, add half the width or height to the top-left coord.
snibgo's IM pages: im.snibgo.com
Post Reply