Page 1 of 1
draw -text not working in windows
Posted: 2012-03-10T08:00:12-07:00
by salsaman
I'm using the windows binaries from the site. If I do something like:
convert -quiet -colorspace RGB -type truecolor -alpha on temp.png -fill #FFFFFF -stroke #FFFFFF -pointsize 32 -draw 'text 90 100 "ABC"' +matte 00000001.png
this works fine under Linux, but under windows (well, wine to be exact), it says:
Non-conforming drawing primitive definition `text' @ error/draw.c/DrawImage/3146
Does text drawing not work under windows, or am i doing something wrong ?
Re: draw -text not working in windows
Posted: 2012-03-10T08:58:40-07:00
by Bonzo
For windows you need to replace ' ' with " "
Try:
Code: Select all
convert -quiet -colorspace RGB -type truecolor -alpha on temp.png -fill #FFFFFF -stroke #FFFFFF -pointsize 32 -draw "text 90 100 'ABC' " +matte 00000001.png
Re: draw -text not working in windows
Posted: 2012-03-10T13:39:22-07:00
by salsaman
Thanks, that kind of works, but now it gives another error:
convert.exe: unable to read font `(null)' @ error/annotate.c/RenderFreetype/1120.
convert.exe: `%s' (%d) "C:/Program Files/gs/gs9.05/bin/gswin32c.exe" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -g160x64 "-sOutputFile=C:/users/xxx/Temp/magick-q83HRKXE--0000001" "-fC:/users/xxx/Temp/magick-Yb_uaiS1" "-fC:/users/gabriel/Temp/magick-uMOBGst4" @ error/utility.c/SystemCommand/1896.
and if I try specify the font with e.g. -font Helvetica:
convert.exe: unable to read font `Helvetica' @ error/annotate.c/RenderFreetype/1120.
Re: draw -text not working in windows
Posted: 2012-03-10T14:01:33-07:00
by Bonzo
Your code looks a bit complicated if all you are doing is writing text on an image. It might be an idea to post an example of what result you are looking for.
Re: draw -text not working in windows
Posted: 2012-03-10T16:22:08-07:00
by fmw42
convert -quiet -colorspace RGB -type truecolor -alpha on temp.png -fill #FFFFFF -stroke #FFFFFF -pointsize 32 -draw "text 90 100 'ABC' " +matte 00000001.png
your syntax is not proper or IM 6. The png input should be read first before any options. But the main problem is why you are enabling alpha when you are using opaque colors. -alpha on is at odds with +matte which turns off transparency.
And hex and rgb colors must be enclosed in quotes.
If your input does not have transparency, then this should work
convert -quiet temp.png -fill "#FFFFFF" -stroke "#FFFFFF" -pointsize 32 -draw "text 90 100 'ABC' " 00000001.png
If your input png has transparency, then you need to specify your colors, I think, with opaque alpha values, such as #FFFFFF00. See if these changes help.
convert -quiet temp.png -alpha on -fill "#FFFFFF00" -stroke "#FFFFFF00" -pointsize 32 -draw "text 90 100 'ABC' " 00000001.png
Re: draw -text not working in windows
Posted: 2012-03-11T08:25:27-07:00
by salsaman
fmw42 wrote:convert -quiet -colorspace RGB -type truecolor -alpha on temp.png -fill #FFFFFF -stroke #FFFFFF -pointsize 32 -draw "text 90 100 'ABC' " +matte 00000001.png
your syntax is not proper or IM 6. The png input should be read first before any options. But the main problem is why you are enabling alpha when you are using opaque colors. -alpha on is at odds with +matte which turns off transparency.
And hex and rgb colors must be enclosed in quotes.
If your input does not have transparency, then this should work
convert -quiet temp.png -fill "#FFFFFF" -stroke "#FFFFFF" -pointsize 32 -draw "text 90 100 'ABC' " 00000001.png
If your input png has transparency, then you need to specify your colors, I think, with opaque alpha values, such as #FFFFFF00. See if these changes help.
convert -quiet temp.png -alpha on -fill "#FFFFFF00" -stroke "#FFFFFF00" -pointsize 32 -draw "text 90 100 'ABC' " 00000001.png
Sorry, yes, the input does have quotes now. I was using ' originally but I changed to " for windows.
The part "convert -quiet -colorspace RGB -type truecolor -alpha on" is standard for png for my application - basically this is my standardised "convert command" which I arrived at by trial and error. This part *cannot* be changed in the application.
Now I have to use +matte, else there is some truly horrible anti-aliasing going on for the text. As I said, all of this works perfectly under Linux. It may well be though that adding the alpha values to the colour strings will fix this. Thanks for that suggestion. But surely "00" is transparent, so I would want "FF" for opaque ?
Regardless of all this, it seems from the error output that the problem in windows is that the fonts are simply not being found.
So my question is - how to add the fonts and make imagemagick find them ?
Re: draw -text not working in windows
Posted: 2012-03-11T11:55:21-07:00
by fmw42
Your syntax is still improper for IM 6, but may still work. see
http://www.imagemagick.org/Usage/basics/#cmdline
With regard to not finding your fonts, I don't know how to do that in windows. In unix Anthony has a script. I think you may need to manually edit the type.xml file, but don't really know about that for Windows. In the mean time, just put the full path to your font and it should work properly. Don't forget to quote the hex colors.