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 ?
draw -text not working in windows
Re: draw -text not working in windows
For windows you need to replace ' ' with " "
Try:
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
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.
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
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.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: draw -text not working in windows
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.convert -quiet -colorspace RGB -type truecolor -alpha on temp.png -fill #FFFFFF -stroke #FFFFFF -pointsize 32 -draw "text 90 100 'ABC' " +matte 00000001.png
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
fmw42 wrote: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.convert -quiet -colorspace RGB -type truecolor -alpha on temp.png -fill #FFFFFF -stroke #FFFFFF -pointsize 32 -draw "text 90 100 'ABC' " +matte 00000001.png
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 ?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: draw -text not working in windows
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.
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.