Does -encoding work?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Jaclaw

Does -encoding work?

Post by Jaclaw »

I have IM 6.4.1 installed on my Debian server and have serious problems with writing national/Unicode characters with any functions.
Whatever I write in encoding param, it doe's not matter. The output stays the same.

I tried to convert UTF-8 formated text from this example:
http://www.cl.cam.ac.uk/~mgk25/ucs/exam ... 8-demo.txt
with this command:

Code: Select all

convert -background lightblue -encoding 'Unicode' -fill blue label:@UTF-8-demo.txt test.gif
...and the effect is always like that:
Image



A simple example from:
http://www.imagemagick.org/Usage/text/#unicode

Code: Select all

 env LC_CTYPE=en_AU.utf8 \
    printf "\u2018single\u2019 - \u201Cdouble\u201D" | \
      convert -background lightblue -fill blue -pointsize 36 \
              label:@-  label_quotes.gif
produces:
Image

What do I do wrong?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Does -encoding work?

Post by anthony »

It looks as if your "printf" command did not convert \u unicode charcater codes to actual unicode characters. You will need to find some way to do this.

Hmmm if you have perl on you system its printf's should handle unicode generation...

For example...

Code: Select all

   perl -e 'binmode(STDOUT, ":utf8"); \
            print "\x{6d4b}\x{8bd5}\x{7528}\x{7684}\x{6c49}\x{5b57}\n";'

   perl -e 'binmode(STDOUT, ":utf8");
     print pack("U*", 0x6d4b, 0x8bd5, 0x7528, 0x7684, 0x6c49, 0x5b57), "\n";'
Pipe the output of one of the above commands into the IM convert command. You also need a unicode font too, that has those characters in it. Such as the "SimSun" chinese font.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply