Page 1 of 1

creating trim marks on different sized images

Posted: 2014-03-26T10:42:41-07:00
by holden
Hey all, I need to make several templates with trim marks in the corners. I'm not sure how to do math in IM. To start I would need this:

convert -size 2400x3000 xc:white ^
-draw "line 0,0 0,100" ^
-draw "line 0,0 100,0" ^
for the first corner, then
-draw "line 2300,0 2400, 0"^
-draw "line 2400, 0 2400,100" ^
for the adjacent corner, and on and on. But, since I need to do this for different sizes, it'd be easier to have formulas in place of the coords in the -draw command. Can I pull numbers from the initial size values? I can input the different size parameters manually but I'd like the rest to be automated. Thanks

Re: creating trim marks on different sized images

Posted: 2014-03-26T10:58:44-07:00
by snibgo
I would put both lines in a single draw, and use translate, eg:

Code: Select all

convert -size 2400x3000 xc:white -draw "translate 20,20 line 0,0 0,100 line 0,0 100,0" x.png
"-draw" follows SVG rules, so "translate" comes before "line", not after.

I don't think you can use a formula inside "-draw", so you need to use environment variables.

Re: creating trim marks on different sized images

Posted: 2014-03-26T11:18:04-07:00
by holden
Thanks for the response, I think it may be faster for me to do this in Gimp than to figure out the code-y way :lol:

Re: creating trim marks on different sized images

Posted: 2014-03-26T11:41:54-07:00
by fmw42
You can make a template image of one tick mark (cross?) using -draw on a transparence background (or find an appropriate symbol graphic). Then just composite it at several locations as desired. You can even read it once and use clones or mpr to composite it.

see
http://www.imagemagick.org/Usage/layers/#convert
http://www.imagemagick.org/Usage/layers/#flatten
http://www.imagemagick.org/Usage/basics/#parenthesis
http://www.imagemagick.org/Usage/basics/#clone
http://www.imagemagick.org/Usage/files/#mpr

Here is an example using the IM internal image logo:

Unix format:

convert logo: \
\( -size 100x100 xc:none -fill black -draw "line 50,0 50,100 line 0,50 100,50" -write mpr:tic +delete \) \
mpr:tic -gravity northwest -geometry +50+50 -compose over -composite \
mpr:tic -gravity northeast -geometry +50+50 -compose over -composite \
mpr:tic -gravity southeast -geometry +50+50 -compose over -composite \
mpr:tic -gravity southwest -geometry +50+50 -compose over -composite \
logo_tics.gif

Windows format:

convert logo: ^
( -size 100x100 xc:none -fill black -draw "line 50,0 50,100 line 0,50 100,50" -write mpr:tic +delete ) ^
mpr:tic -gravity northwest -geometry +50+50 -compose over -composite ^
mpr:tic -gravity northeast -geometry +50+50 -compose over -composite ^
mpr:tic -gravity southeast -geometry +50+50 -compose over -composite ^
mpr:tic -gravity southwest -geometry +50+50 -compose over -composite ^
logo_tics.gif