Stroke around output

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
pctechtv
Posts: 22
Joined: 2016-10-09T19:47:59-07:00
Authentication code: 1151

Stroke around output

Post by pctechtv »

I have an ImageMagick command I use like so.

Code: Select all

magick -density 72 "C:\ExamplePDF\MyPDF.pdf"[0] -crop %[w]x%[fx:w/16*9]+0+0 +repage -resize 765x430 "C:\ExampleJPG\MyJPG.jpg"
I am wondering if it is possible to get a stroke around my jpeg output like so (pic). If so could someone show me the command. Thanks
Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Stroke around output

Post by fmw42 »

Code: Select all

convert image -bordercolor black -border 2 result
see http://www.imagemagick.org/Usage/crop/#border
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Stroke around output

Post by GeeMack »

pctechtv wrote:I am wondering if it is possible to get a stroke around my jpeg output like so (pic). If so could someone show me the command.
If you want to add a border without changing the existing dimensions of the image you can "-shave" it first to reduce the image size by the border size. Then add the border. Use the same amount for both the "-shave" and the "-border" like this...

Code: Select all

magick input.jpg -bordercolor blue -shave 3x3 -border 3x3 output.jpg
The output image there will be the same dimensions as the input image.
pctechtv
Posts: 22
Joined: 2016-10-09T19:47:59-07:00
Authentication code: 1151

Re: Stroke around output

Post by pctechtv »

I am not getting any of the examples to work. It is making ask the question if I am on Windows and run the "convert" command could I be not in ImageMagicks context. I keep getting errors like

Code: Select all

Invalid Parameter - -bordercolor
whine I use the command like this

Code: Select all

convert 'D:\161122 TempCodePic\Test2.jpg' -bordercolor black -border 2 'D:\161122 TempCodePic\Test3.jpg'
I even saw other examples using it like this

Code: Select all

convert -bordercolor red -border 10 "D:\161122 TempCodePic\Test2.jpg" "D:\161122 TempCodePic\Test3.jpg" 
but still get the error. Thanks
pctechtv
Posts: 22
Joined: 2016-10-09T19:47:59-07:00
Authentication code: 1151

Re: Stroke around output

Post by pctechtv »

When I use it with the "magick" command instead of "convert" it works. I would like to know what is going on here. However it does do EXACTLY what I was trying to do. Thank you @fmw42 and @GeeMack
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Stroke around output

Post by GeeMack »

pctechtv wrote:I am not getting any of the examples to work. It is making ask the question if I am on Windows and run the "convert" command could I be not in ImageMagicks context. I keep getting errors like

Code: Select all

Invalid Parameter - -bordercolor
There is a Windows program named "convert.exe", and your command was calling that program. Since you have ImageMagick 7 you'll probably want to use "magick" instead anyway.
Post Reply