convert command gives error in bash script
Posted: 2018-05-01T04:46:07-07:00
I am using
$ convert --version
Version: ImageMagick 6.8.9-9 Q16 x86_64 2017-07-31 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png rsvg tiff wmf x xml zlib
in 64 bit ubuntu OS.
Here is my script
[script]
#!/bin/bash
img_file=$2
while read one_line; do
let "first_num = $(echo $one_line|cut -d ' ' -f1)"
let "second_num = $(echo $one_line|cut -d ' ' -f2)"
echo first num-$first_num
echo second num-$second_num
let "periphery = $((second_num+5))"
echo periphery-$periphery
convert /home/lxuser/Downloads/xyt/$img_file -fill none -strokewidth 1 -draw \'"circle $first_num,$second_num $first_num,$periphery"\' \'"/home/lxuser/Downloads/xyt/$img_file"\'
echo convert /home/lxuser/Downloads/xyt/$img_file -fill none -strokewidth 1 -draw \'"circle $first_num,$second_num $first_num,$periphery"\' \'"/home/lxuser/Downloads/xyt/$img_file"\'
done < $1
[/script]
I pass it two files
(1)sth.xyt which is of the form
13 146 202 6
23 251 22 15
26 51 180 17
30 224 34 15
33 263 202 34
35 455 225 7
46 176 202 67
58 109 191 33
61 151 202 33
63 47 180 35
(2)<image_file>
The script takes first two numbers and draws circle of radius 5 on the image_file passed as second argument .
Strangely, I get error (in red)
first num-13
second num-146
periphery-151
convert: non-conforming drawing primitive definition `circle 13,146 13,151' @ error/draw.c/DrawImage/3184.
convert /home/lxuser/Downloads/xyt/don.jpg -fill none -strokewidth 1 -draw 'circle 13,146 13,151' '/home/lxuser/Downloads/xyt/don.jpg'
If I simply copy paste the echoed command . it works.
$ convert --version
Version: ImageMagick 6.8.9-9 Q16 x86_64 2017-07-31 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png rsvg tiff wmf x xml zlib
in 64 bit ubuntu OS.
Here is my script
[script]
#!/bin/bash
img_file=$2
while read one_line; do
let "first_num = $(echo $one_line|cut -d ' ' -f1)"
let "second_num = $(echo $one_line|cut -d ' ' -f2)"
echo first num-$first_num
echo second num-$second_num
let "periphery = $((second_num+5))"
echo periphery-$periphery
convert /home/lxuser/Downloads/xyt/$img_file -fill none -strokewidth 1 -draw \'"circle $first_num,$second_num $first_num,$periphery"\' \'"/home/lxuser/Downloads/xyt/$img_file"\'
echo convert /home/lxuser/Downloads/xyt/$img_file -fill none -strokewidth 1 -draw \'"circle $first_num,$second_num $first_num,$periphery"\' \'"/home/lxuser/Downloads/xyt/$img_file"\'
done < $1
[/script]
I pass it two files
(1)sth.xyt which is of the form
13 146 202 6
23 251 22 15
26 51 180 17
30 224 34 15
33 263 202 34
35 455 225 7
46 176 202 67
58 109 191 33
61 151 202 33
63 47 180 35
(2)<image_file>
The script takes first two numbers and draws circle of radius 5 on the image_file passed as second argument .
Strangely, I get error (in red)
first num-13
second num-146
periphery-151
convert: non-conforming drawing primitive definition `circle 13,146 13,151' @ error/draw.c/DrawImage/3184.
convert /home/lxuser/Downloads/xyt/don.jpg -fill none -strokewidth 1 -draw 'circle 13,146 13,151' '/home/lxuser/Downloads/xyt/don.jpg'
If I simply copy paste the echoed command . it works.