Command Line Image:
I want 3 25x25 colored blocks, each block should contain a number.
convert -size 25x25 xc:#FFFFFF -gravity center -fill black -annotate +0 '1' -size 25x25 xc:#FFFFFF -gravity center -fill black -annotate +0 '2' -size 25x25 xc:#FFFFFF -gravity center -fill black -annotate +0 '3' +append capimg.png
That will produce 3 white blocks 25x25, the first block will have 1 2 and 3 annotated on it, the second block will have 2 and 3 annotated on it, and the third block will have the expected 3 annotated on it.
The blocks are white (FFFFFF) for example, in reality, I'll use different colors, but for simplicity, I'm using FFFFFF here.
I need the first and second block to only print 1 and 2 respectively without having other numbers written on top.
Thanks!
Annotate is repeating on every image.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Annotate is repeating on every image.
You need to use parenthesis processing to keep each part separate.
In Windows remove the \ from the parenthesis and replace the \ at the end of the lines with ^
See https://imagemagick.org/Usage/basics/#parenthesis
Please always provide your IM version and platform when asking questions. This avoid repeating of commands for Windows and Unix
Code: Select all
convert \
\( -size 25x25 xc:#FFFFFF -gravity center -fill black -annotate +0 '1' \) \
\( -size 25x25 xc:#FFFFFF -gravity center -fill black -annotate +0 '2' \) \
\( -size 25x25 xc:#FFFFFF -gravity center -fill black -annotate +0 '3' \) \
+append capimg.png
See https://imagemagick.org/Usage/basics/#parenthesis
Please always provide your IM version and platform when asking questions. This avoid repeating of commands for Windows and Unix
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: Annotate is repeating on every image.
When using "-annotate" you can include FX expressions within the text, and let the command increment the numbers for you. Here's an example...
Code: Select all
convert -size 25x25 xc:white xc:yellow xc:pink \
-gravity center -pointsize 12 -annotate +0 %[fx:t+1] -scene 1 out%d.png
For Windows, replace the continued line backslash "\" with a caret "^".
If you're using IM version 7, use "magick" instead of "convert".
Re: Annotate is repeating on every image.
Yup, that was it, thanks.
Interestingly I wasn't able to put it on one line in my php code running on Ubuntu Linux like:
ecec('convert \( -size 25x25 xc:#FFFFFF -gravity center -fill black -annotate +0 \'1\' \) \( -size 25x25 xc:#FFFFFF -gravity center -fill black -annotate +0 \'2\' \) \( -size 25x25 xc:#FFFFFF -gravity center -fill black -annotate +0 \'3\' \) +append capimg.png');
I actually had to put it in several lines:
exec('convert \
\( -size 25x25 xc:#FFFFFF -gravity center -fill black -annotate +0 \'1\' \) \
\( -size 25x25 xc:#FFFFFF -gravity center -fill black -annotate +0 \'2\' \) \
\( -size 25x25 xc:#FFFFFF -gravity center -fill black -annotate +0 \'3\' \) \
+append capimg.png');
Taking out the end line slash didn't seem to make a difference. Though, it's possible I missed a slash.
Interestingly I wasn't able to put it on one line in my php code running on Ubuntu Linux like:
ecec('convert \( -size 25x25 xc:#FFFFFF -gravity center -fill black -annotate +0 \'1\' \) \( -size 25x25 xc:#FFFFFF -gravity center -fill black -annotate +0 \'2\' \) \( -size 25x25 xc:#FFFFFF -gravity center -fill black -annotate +0 \'3\' \) +append capimg.png');
I actually had to put it in several lines:
exec('convert \
\( -size 25x25 xc:#FFFFFF -gravity center -fill black -annotate +0 \'1\' \) \
\( -size 25x25 xc:#FFFFFF -gravity center -fill black -annotate +0 \'2\' \) \
\( -size 25x25 xc:#FFFFFF -gravity center -fill black -annotate +0 \'3\' \) \
+append capimg.png');
Taking out the end line slash didn't seem to make a difference. Though, it's possible I missed a slash.