Page 1 of 1

Border width depends on image dimensions

Posted: 2016-05-08T03:38:33-07:00
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

Re: Border width depends on image dimensions

Posted: 2016-05-08T05:05:44-07:00
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.

Re: Border width depends on image dimensions

Posted: 2016-05-08T07:17:17-07:00
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.

Re: Border width depends on image dimensions

Posted: 2016-05-08T07:30:08-07:00
by snibgo
"convert" is a legacy program. Try it with "magick".

Re: Border width depends on image dimensions

Posted: 2016-05-08T09:56:40-07:00
by Erik
Yay, it works.

Thanks!

Re: Border width depends on image dimensions

Posted: 2016-05-08T11:00:46-07:00
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