imagemagickunicode-string

Imagemagick annotate with Unicode characters


How can I draw Unicode characters in Imagemagick using -annotate ?

My spurce file is UTF-8

This is my code:

"C:\Program Files\ImageMagick-7.1.1-Q8\magick.exe" convert -size 800x200 xc:black -font Times -fill #808080 -gravity Center -pointsize 64 -annotate +0+0 "ABCDEF - Ê" text.png

What I get is this image enter image description here


Solution

  • You face a mojibake case (example in Python for its universal intelligibility):

    print( 'ABCDEF - Ê'.encode( 'utf-8').decode( 'cp850'))
    
    ABCDEF - Ê
    

    In terms of Windows command line: suppose that the following 76126154.bat batch script contains the only command line @echo ABCDEF - Ê and is saved as UTF-8 (without Byte order mark).

    Run the script using UTF-8 as active console Code Page. Otherwise, you see mojibake as follows:

    chcp
    :: Active code page: 850
    
    76126154.bat
    :: ABCDEF - Ê
    
    chcp 65001
    :: Active code page: 65001
    
    76126154.bat
    :: ABCDEF - Ê