Image border size calculated from image size

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
pnowak
Posts: 4
Joined: 2019-05-30T11:03:02-07:00
Authentication code: 1152

Image border size calculated from image size

Post by pnowak »

Some parameters calculated. But something is wrong:

OS Windows 7 pro.
ImageMagick 7.0.8Q16

Constant parameters (first -annotate) work:

Code: Select all

convert %1 -bordercolor Black -border 64x64 -font Gadugi -pointsize 36 -fill white -gravity southwest -annotate 0x0+64+10 "%%[EXIF:ImageDescription]" -gravity southeast -annotate 0x0+64+10 "TEXT" %1b.jpg"
Calculated parameters (first -annotate) don't work:

Code: Select all

convert %1 -bordercolor Black -border 64x64 -font Gadugi -pointsize 36 -fill white -gravity southwest -annotate "0x0+%%[fx:min(h,w)/50]+10" "%%[EXIF:ImageDescription]" -gravity southeast -annotate 0x0+64+10 "TEXT" %1b.jpg"
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image border size calculated from image size

Post by fmw42 »

What happens? Can you show the two results? You can upload to some free hosting service and put the URLs here.

What is your exact IM 7 version (7.x.x.x)?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Image border size calculated from image size

Post by snibgo »

pnowak wrote:Calculated parameters (first -annotate) don't work: ...
Use "magick" instead of "convert".
snibgo's IM pages: im.snibgo.com
pnowak
Posts: 4
Joined: 2019-05-30T11:03:02-07:00
Authentication code: 1152

Re: Image border size calculated from image size

Post by pnowak »

version 7.0.8-Q16

I need to calculate some parameters from size of image. But imageMAgick documentation seems very poor to me. I'm not able to find: how to calculate, where get image size, etc.... So I try some examples but without success.

"-border 0x0+64+10" works.

I need to calculate "min(imageHeight,imageWidth)/50" instead of 64.

is it right?

-border "0x0+%%[fx:min(h,w)/50]+10"

It returns eror:
convert: invalid argument for option '-border': %[fx:w/50]x64 @ error/convert.c/ConvertImageCommand/839.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Image border size calculated from image size

Post by snibgo »

As I said: Use "magick" instead of "convert".
snibgo's IM pages: im.snibgo.com
pnowak
Posts: 4
Joined: 2019-05-30T11:03:02-07:00
Authentication code: 1152

Re: Image border size calculated from image size

Post by pnowak »

@snibgo:

really? That way?

"C:\Program Files\ImageMagick-7.0.8-Q16\magick.exe" magick %1 -bordercolor Black -border 50%x50% -font Gadugi -pointsize 36 -fill white -gravity southwest -annotate 0x0+64+10 "%%[EXIF:ImageDescription]" -gravity southeast -annotate 0x0+64+10 "TEXT" %1b.jpg"
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Image border size calculated from image size

Post by snibgo »

pnowak wrote:"C:\Program Files\ImageMagick-7.0.8-Q16\magick.exe" magick %1 ...
No. I said: Use "magick" instead of "convert". You have "magick" twice. And you've removed "%[fx...]" from your "-border" and "-annotate".
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image border size calculated from image size

Post by fmw42 »

Most inline computations do not work in ImageMagick 6 (with convert). But they do work in ImageMagick 7 (with magick replacing convert).
pnowak
Posts: 4
Joined: 2019-05-30T11:03:02-07:00
Authentication code: 1152

Re: Image border size calculated from image size

Post by pnowak »

@snibgo + fmw42: Perfect. It works now. Thanks !!!
Post Reply