overlaying a canvas on an image

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
user001
Posts: 30
Joined: 2015-11-02T01:21:03-07:00
Authentication code: 1151

overlaying a canvas on an image

Post by user001 »

I am trying to overlay a canvas (specifically a white rectangle of defined size) on an image. The following command, which I expect to overlay a rectangle of 100 pixel width and 4 pixel height, does not overlay a rectangle of the expected size:

convert file.tif -gravity center -crop 50%x50% 'xc:white[100x4!]' -gravity southeast -geometry +10+10 -composite x:

I have tried various permutations, but the pixel size of the rectangle is not correct. For instance, when file.tif has dimensions 333x390, the white bar is longer than half the image width, which should not be the case. Please advise on how the task can be accomplished properly. Thank you.

PS: I am using ImageMagick 6.8.9-9 Q16 x86_64 2015-01-05 on a Debian 8 system.
Last edited by user001 on 2015-11-02T02:42:09-07:00, edited 2 times in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: overlaying a canvas on an image

Post by snibgo »

Why do you have "-geometry 50%x50%"? What do you want that to do?
snibgo's IM pages: im.snibgo.com
user001
Posts: 30
Joined: 2015-11-02T01:21:03-07:00
Authentication code: 1151

Re: overlaying a canvas on an image

Post by user001 »

Apologies, it was supposed to be "crop." I edited the post to make this correction.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: overlaying a canvas on an image

Post by snibgo »

Okay. Did that solve the problem? It would be usual to put "-crop 50%x50%+0+0", with "+repage", but that makes no difference to the image.

If that didn't solve it, please show your input and output. You can put them somewhere like dropbox.com and paste the URLs here.
snibgo's IM pages: im.snibgo.com
user001
Posts: 30
Joined: 2015-11-02T01:21:03-07:00
Authentication code: 1151

Re: overlaying a canvas on an image

Post by user001 »

Oh, indeed! I just checked my terminal emulator history and found that I made the same mistake (trying to use the syntax "-geometry X%xY% -crop" instead of "-crop X%xY%"). A regrettable error, for the resolution of which I convey my sincerest thanks.
Post Reply