trim set of images same amount

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
utnuc
Posts: 12
Joined: 2014-09-17T06:41:13-07:00
Authentication code: 6789

trim set of images same amount

Post by utnuc »

I've got a set of stills extracted from a video that I'd like to process the same way, but when I apply -trim to each still they are getting trimmed a tad different each time (when they should have the exact amount of black space on every still. Is there a way to get the average trim of a set and apply it to each one? Here's my code:

Code: Select all

convert in.png -trim +repage out.png
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: trim set of images same amount

Post by fmw42 »

try

Code: Select all

cd to directory of images
convert * -format "%@" info:
See http://www.imagemagick.org/script/escape.php


You can then process all the data to get the average width, height, xoffset and yoffset and then use -crop WxH+X+Y +repage, but it depends upon your OS for scripting.

Please always provide your IM version and platform when asking questions to save a lot of back and forth questions and answers.
utnuc
Posts: 12
Joined: 2014-09-17T06:41:13-07:00
Authentication code: 6789

Re: trim set of images same amount

Post by utnuc »

this worked brilliantly with a little bash scripting. Thanks fmw42!
Post Reply