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?".
I'm resizing images to a fixed width but the height varies every time. I would like to add a rounded border which requires knowing the dimensions of the new image. The following code creates an image of some text on white background with some padding.
convert -background white -fill black \
-font Helvetica -pointsize 200 label:"TEXT HERE" \
-bordercolor white -border 20x20 \
-resize 300 \
image.png
According to one of the usage pages I could use 'roundrectangle 1,1 %[fx:w-10],%[fx:h-10] 15,15' but the parameters are not substituted in the -draw command. Is there a solution other than using a temp file? I would like to have all this done in the same pass. Is this possible?
Currently that is next to imposible from the same command using the command line. It is easy in a language API where you can stop to extract information about images to create the arguments for later operations.
One method using multiple commands is shown in ... http://www.imagemagick.org/Usage/thumbn ... ded_border
A shell can also read the output from identify and calculate the arguments for the next command, but that means saving the intermediate image in some temporary file such as MIFF: of MPC: See IM exmaples 'files' for details of these formats.
Also look at the script "de-pixelate" and "jigsaw" in IM example scripts area for ways to handling temporary files.
There is plans to add some special extra syntax to set command line arguments basied on images in memory. It is on hold while I think about it and finish up some other additions to IM (distortion resampling and color auto-levels). Though even that solution would not pass that type of into into 'draw' commands as that interface is rescrited by its need to handle SVG images correctly.