Crop and border in the wrong order?

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
lenscape

Crop and border in the wrong order?

Post by lenscape »

Hi

The following:

Code: Select all

			convert \
				-crop +0+100 \
				-bordercolor silver \
				-border 10 \
				in.jpg \
				out.jpg
seems to do the border before the crop so the top border is cropped out of existence.

I've tried reordering the options but I can't simply get the image cropped then add the border to what's left.

I've tried using chop, too and I seem to end up with just the border!

Short of piping one convert with a crop into another convert with the border, I'm running short if ideas. What should I be doing? Thanks.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Crop and border in the wrong order?

Post by anthony »

Why do you expect IM to understand that you want things done in a particular order, when you don't tell IM the right order to do thing in. :?

You can't crop and add borders to an image that you have not read.
In fact IM probably should throw an error (or at least a warning).
But being the responsible program it is it justs trys its best to do what you asked.

What it did was a 'legacy mode' for backward compatibilty.
IM Examples, Legacy Mode
http://www.imagemagick.org/Usage/basics/#legacy
Just save up all the options, and do them when an image had been finally given.
This is a throw back to the bad old IM version 5 days, where this try of thing happened all the time.

If your READ in the image BEFORE you operate on it, it will work as expected...

Code: Select all

 convert \
            in.jpg \
            -crop +0+100 \
            -bordercolor silver \
            -border 10 \
            out.jpg
and all will be done in the order you expect because you gave it in the order YOU want it to be done in.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
lenscape

Re: Crop and border in the wrong order?

Post by lenscape »

Thanks for that. It did the trick although I thought I'd already tried that approach.
Post Reply