Page 1 of 1

Black line / linea nigra / черная линия

Posted: 2011-03-27T13:29:13-07:00
by ghostmansd
Dear forum-users, is it possible to draw a black line, dividing an image? I need to draw a black line between pages to make Scan Talor recognize that file consists of two pages.
Debeo scriptvm, qvod cognoscit, si pagina duas paginas inclvdit. Si inclvdit, scriptvm has paginas una linea nigra dividit. Alteri applicationi interest, ut linea nigra sit.
Уважаемые форумчане, возможно ли нарисовать черную линию, разделяющую картинку на две части? Это необходимо для дальнейшей работы в Scan Tailor.
Image

Re: Black line / linea nigra / черная линия

Posted: 2011-03-27T13:50:25-07:00
by fmw42
see -draw "line x1,y1 x2,y2" http://www.imagemagick.org/Usage/draw/#primitives

convert inputimage -stroke black -stroke-width 1 -draw "line x1,y1 x2,y2" resultimage

Re: Black line / linea nigra / черная линия

Posted: 2011-03-27T14:07:26-07:00
by ghostmansd
fmw42 wrote:see -draw "line x1,y1 x2,y2" http://www.imagemagick.org/Usage/draw/#primitives

convert inputimage -stroke black -stroke-width 1 -draw "line x1,y1 x2,y2" resultimage
Is it possible to get image size to know where to draw line? It seems that x1=1, y1=height/2, x2=width, y2=height/2.

Re: Black line / linea nigra / черная линия

Posted: 2011-03-27T14:41:46-07:00
by fmw42
Is it possible to get image size to know where to draw line? It seems that x1=1, y1=height/2, x2=width, y2=height/2.
On Linux/Mac,

ww=`convert image -ping -format "%[fx:w-1]" info:`
hh=`convert image -ping -format "%[fx:h/2]" info:`
convert inputimage -stroke black -draw "line 0,$hh $ww,$hh" resultimage

see -string format and -fx escapes
http://www.imagemagick.org/script/escape.php
http://www.imagemagick.org/Usage/transform/#fx_escapes

I don't believe that -draw allows calculation within its arguments. But I could be wrong.

For Windows, see http://www.imagemagick.org/Usage/windows/

Re: Black line / linea nigra / черная линия

Posted: 2011-03-27T14:47:38-07:00
by ghostmansd
I mean that what you've said. I've already decided this problem in a such way:
SZX=$(identify -format "%w" "$IMG")
SZY=$((SZY=$(identify -format "%h" "$IMG") / 2))
convert "$IMG" -white-threshold 75% -stroke black -strokewidth 10 -draw "line 1,$SZY $SZX,"$SZY"" "$IMG"

But your way is much easer. Thanks!

Re: Black line / linea nigra / черная линия

Posted: 2011-03-27T15:31:31-07:00
by fmw42
You can also do:

coords=`convert inputimage -ping -format "0,%[fx:h/2] %[fx:w-1],%[fx:h/2]" info:`
convert inputimage -stroke black -draw "line $coords" resultimage

or


coords=$(convert inputimage -ping -format "0,%[fx:h/2] %[fx:w-1],%[fx:h/2]" info:)
convert inputimage -stroke black -draw "line $coords" resultimage

Re: Black line / linea nigra / черная линия

Posted: 2011-03-27T21:29:31-07:00
by anthony
fmw42 wrote:
I don't believe that -draw allows calculation within its arguments. But I could be wrong.
Your not. At least not at this time. This may change, but at this time Percent escapes are not permitted by 'Draw'
arguments.

NOTE in the example image the center of the image is not the center of the book!

And finally you can draw beyond the image bounds, if that make things easier. Anything outsid ethe image proper is just ignored. As such you don't really have to worry about using %[fx:w-1] when %w will work just as well.