How to use imageMagick on Chinese Text to Image Handling

1

I try to use ImageMagick to handle a Chinese character to a image on my MacBook.

According to ImageMagick's guide Unicode or UTF8 Format Text, I tried two ways.

Code one:

convert -background lightblue -fill blue \
-size 165X270 -pointsize 24 \
-gravity center -font Andale Mono \
label:'中' label.png

Code two:

I write the Chinese character in a text file, and add .utf8 to its file name.

convert -background lightblue -fill blue \
-size 165X270 -pointsize 24 \
-gravity center -font Andale Mono \
label:@chin.utf8 label.png

Both do not work. And the result is the same

enter image description here

Many Thanks In Advance , :-)

dengApro

Posted 2017-12-12T14:06:35.837

Reputation: 241

1You need to use a TTF file that contains Chinese characters in it - then it will work fine. "Andale Mono" is not the right choice. – Mark Setchell – 2017-12-12T15:59:37.557

Yes, I will try. i asked a question https://stackoverflow.com/questions/47775394/how-to-use-imagemagick-with-chinese-fonts-on-text-to-image-handling

– dengApro – 2017-12-12T16:10:36.217

ps: I could not get your @chin.utf8 command to work. – Matt Sephton – 2017-12-13T10:37:31.317

I write the Chinese character in a text file, and add .utf8 to its file name. That is chin.utf8 file – dengApro – 2017-12-13T10:52:47.097

Answers

1

Use a font that contains Chinese characters, best thing to do is use a Unicode font.

convert -background lightblue -fill blue \ -size 165X270 -pointsize 24 \ -gravity center -font "/Library/Fonts/Arial Unicode.ttf" \ label:'中' label.png

You can easily find suitable fonts using macOS Font Book app.

Matt Sephton

Posted 2017-12-12T14:06:35.837

Reputation: 278

@dengApro done! :) – Matt Sephton – 2017-12-13T11:26:10.900

0

An instance answer:

convert -background lightblue -fill blue \
-size 165X270 -pointsize 24 \
-gravity center -font "/Library/Fonts/Microsoft/Kaiti.ttf" \ label:'好' labelOne.png

Thank Matt Sephton's guide

dengApro

Posted 2017-12-12T14:06:35.837

Reputation: 241