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?".
Hi, thanks for the speedy reply. I want to apply the trim that happened to the processed image to original image. I'm using a morphology and edge detection to make the image more friendly to trimming, but I effectively want to record the trim on the processed image and apply it to the unprocessed image.
To be clear, I'd rather not have to extract any crop parameters and instead (if possible) use the output of the trim of the processed image as a means of cropping the original.
spender wrote:Hi, thanks for the speedy reply. I want to apply the trim that happened to the processed image to original image. I'm using a morphology and edge detection to make the image more friendly to trimming, but I effectively want to record the trim on the processed image and apply it to the unprocessed image.
As fmw42 mentioned, you can access the calculated trim bounding box with the FX escape "%@". A command using that technique might look something like this...
That gets the specs for the trim bounding box from your processed clone, then holds that value in a variable named "trimmer", then deletes the clone to remove it from further processing. After that you use that variable to crop your original image before the output. You can learn more about how to access all sorts of information about the image at this page about FX Escapes.
NOTE: the techniques goes on to with an improvement by 'expanding' the resulting trim bounds using some FX maths.
That is why separate percent escapes for each number may be preferable.
At the time the example was generated two separate commands was needed, but I have added the IMv7 version of the command to the examples, for a one command version. The examples should update in a few hours.