Text to image with Chinese characters
Posted: 2018-10-29T04:27:21-07:00
The following script appears to work OK with normal text
# Convert text in a text file to an image
#
# text2image.ksh Name.txt
#
# Produces: Nametext.png
N=$(basename $1 .txt)
M="$N""Text"
imgconvert -size 1000x1000 xc:white -font "SimSun" -pointsize 56 \
-fill black -annotate +15+80 "@$N.txt" \
"$M".png
However with Chinese font, such as SimSun in the script as above, a `?' mark is inserted
in front of the first line.
eg if a text file contains the Chinese character for `I' 我 (Pinyin wo3) and is saved
as utf8, then the image produced has a question mark`?' in front of the 我 character.
Subsequent lines in the file are OK.
Various Chinese fonts were tried and the result was the same.
# Convert text in a text file to an image
#
# text2image.ksh Name.txt
#
# Produces: Nametext.png
N=$(basename $1 .txt)
M="$N""Text"
imgconvert -size 1000x1000 xc:white -font "SimSun" -pointsize 56 \
-fill black -annotate +15+80 "@$N.txt" \
"$M".png
However with Chinese font, such as SimSun in the script as above, a `?' mark is inserted
in front of the first line.
eg if a text file contains the Chinese character for `I' 我 (Pinyin wo3) and is saved
as utf8, then the image produced has a question mark`?' in front of the 我 character.
Subsequent lines in the file are OK.
Various Chinese fonts were tried and the result was the same.