Border width depends on image dimensions

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
Erik
Posts: 12
Joined: 2016-04-30T00:18:15-07:00
Authentication code: 1151

Border width depends on image dimensions

Post by Erik »

Hello,

I am trying add a border on a specific side. And the border width has to depend on the dimensions of the current image.

The two snippets below result in an error "mogrify: invalid argument for ...".
Obviously the fx is not allowed here.
I read that distort would allow for adding borders, but I don't understand how.

It can't be that hard, but I am new to Image Magick.

Code: Select all

-gravity west -splice '%[fx:h/1.6]x0' +repage \

Code: Select all

-gravity east -extent '%[fx:h/1.6]x%[fx:h]' \
Erik
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Border width depends on image dimensions

Post by snibgo »

Please, always state your version of IM and platform.

It works fine with "magick" v7.0.1-0 (but not "magick mogrify", so you need a script loop).

In legacy programs, including v6, most places that needed numbers could not accept "fx" expressions.
snibgo's IM pages: im.snibgo.com
Erik
Posts: 12
Joined: 2016-04-30T00:18:15-07:00
Authentication code: 1151

Re: Border width depends on image dimensions

Post by Erik »

Thanks, I had to use compile IM 7 on OSX for that.

Code: Select all

Version: ImageMagick 7.0.1-1 Q8 x86_64 2016-05-08 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI 
Delegates (built-in): bzlib djvu fftw fontconfig freetype jng jp2 jpeg lcms lzma openexr png webp wmf x xml zlib
Both versions fail:

Code: Select all

convert sourcecolor/0079.jp2 -gravity west -splice '%[fx:h/1.6]x0' buildcolor/0079.png
convert: invalid argument for option '-splice': %[fx:h/1.6]x0 @ error/convert.c/ConvertImageCommand/2832.

Code: Select all

convert sourcecolor/0079.jp2 -gravity east -extent '%[fx:h/1.6]x%[fx:h]' buildcolor/0079.png
convert: invalid argument for option '-extent': %[fx:h/1.6]x%[fx:h] @ error/convert.c/ConvertImageCommand/1546.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Border width depends on image dimensions

Post by snibgo »

"convert" is a legacy program. Try it with "magick".
snibgo's IM pages: im.snibgo.com
Erik
Posts: 12
Joined: 2016-04-30T00:18:15-07:00
Authentication code: 1151

Re: Border width depends on image dimensions

Post by Erik »

Yay, it works.

Thanks!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Border width depends on image dimensions

Post by fmw42 »

It works for me with convert in IM 7 on Mac OSX Snow Leopard. Convert is supposed to be just a symbolic link to magick on unix systems. Do you still have IM 6 installed?

What do you get from

Code: Select all

convert -version
Post Reply