Page 1 of 1
convert(1) command can't handle multibyte characters
Posted: 2013-04-04T00:15:09-07:00
by Sonam
Hi,
convert(1) command can't handle multibyte characters properly and results the garbled characters.
It's easy to reproduce.. Create a text file which contains multibyte characters and process it with convert(1) as follows.
$ convert label:@test.txt test.png
convert: FreeType library is not available
`/usr/openwin/lib/X11/fonts/TTbitmaps/Arial-Bold14.pcf.Z'.
convert: FreeType library is not available
`/usr/openwin/lib/X11/fonts/TTbitmaps/Arial-Bold14.pcf.Z'.
:
$
You will see the garbled characters in test.png.
$ cat text.txt
ÆüËܸì
Re: convert(1) command can't handle multibyte characters
Posted: 2013-04-04T09:54:46-07:00
by fmw42
convert: FreeType library is not available
Looks like you need to install the FreeType libraray. See
http://www.imagemagick.org/download/delegates/
Re: convert(1) command can't handle multibyte characters
Posted: 2013-04-04T22:31:52-07:00
by Sonam
Freetype Library is already installed on the system.
bash-3.2# pkginfo | grep freetype
system SUNWfreetype2 FreeType2 Font library
bash-3.2# /usr/sfw/bin/convert label:"HELLO" 1.png
convert: FreeType library is not available `/usr/openwin/lib/X11/fonts/TTbitmaps/Arial-Bold14.pcf.Z'.
convert: FreeType library is not available `/usr/openwin/lib/X11/fonts/TTbitmaps/Arial-Bold14.pcf.Z'.
convert: FreeType library is not available `/usr/openwin/lib/X11/fonts/TTbitmaps/Arial-Bold14.pcf.Z'.
bash-3.2#
The above command creates a correct png file despite the warning messages.
The issue is only when multibyte characters are used.
This error is seen with both 2byte char(Japanese) is in the text file and 1byte char(alphabet) is in the text file.
convert: FreeType library is not available `/usr/openwin/lib/X11/fonts/TTbitmaps/Arial-Bold14.pcf.Z'.
although there is this error, the text file successfully gets converted to png when the text file contains 1byte char(alphabet)
Regards,
Sonam
Re: convert(1) command can't handle multibyte characters
Posted: 2013-04-05T09:06:47-07:00
by fmw42
I don't know much about Freetype to comment. But if it is not installed in a place where IM can find it, then IM won't recognize that it is there. Perhaps it is not an acceptable version? Just some things to check.
Re: convert(1) command can't handle multibyte characters
Posted: 2013-04-15T02:35:07-07:00
by Sonam
What should be the correct location of the freetype fonts for IM to work properly ?
Important thing to notice here is that the text file successfully gets converted to png when the text file contains 1byte char(alphabet).
It's not working only with 2byte char(Japanese).
Re: convert(1) command can't handle multibyte characters
Posted: 2013-04-15T09:30:17-07:00
by fmw42
Sonam wrote:What should be the correct location of the freetype fonts for IM to work properly ?
Probably the same locations as where you have installed IM.
Perhaps it is sufficient to be in some location that is in your $PATH. I am not really sure.
Re: convert(1) command can't handle multibyte characters
Posted: 2013-07-15T03:04:53-07:00
by gmr
Any ideas on the issue. The issue is the same as Sonam had mentioned.
bash-3.2# /usr/sfw/bin/convert label:@text_UTF-8.txt out.png
convert: FreeType library is not available `/usr/openwin/lib/X11/fonts/TTbitmaps/Arial-Bold14.pcf.Z'.
convert: FreeType library is not available `/usr/openwin/lib/X11/fonts/TTbitmaps/Arial-Bold14.pcf.Z'.
convert: FreeType library is not available `/usr/openwin/lib/X11/fonts/TTbitmaps/Arial-Bold14.pcf.Z'.
convert: FreeType library is not available `/usr/openwin/lib/X11/fonts/TTbitmaps/Arial-Bold14.pcf.Z'.
convert: FreeType library is not available `/usr/openwin/lib/X11/fonts/TTbitmaps/Arial-Bold14.pcf.Z'.
convert: FreeType library is not available `/usr/openwin/lib/X11/fonts/TTbitmaps/Arial-Bold14.pcf.Z'.
bash-3.2# ls /usr/openwin/lib/X11/fonts/TTbitmaps/Arial-Bold14.pcf.Z
/usr/openwin/lib/X11/fonts/TTbitmaps/Arial-Bold14.pcf.Z
bash-3.2#
So the file exists on the system, even though the error says the freetype library is not available.
So to put a straight question, does imagemagick support multi-byte character conversion?
If yes, can I get pointers on what to look for regarding the issue?
Thanks
Re: convert(1) command can't handle multibyte characters
Posted: 2013-07-17T09:44:54-07:00
by Jason S
gmr wrote:does imagemagick support multi-byte character conversion?
Testing ImageMagick 6.8.6-5 on Linux...
Code: Select all
$ echo -e 'X\xe2\x98\xbaX' > label.txt
$ convert label:@label.txt test.png
My result: X☺X
(I do not get any warnings about FreeType.)
So, it interpreted the label file as UTF-8, and the non-Latin character was correctly processed. This confirms that IM does support multi-byte UTF-8 characters, at least in some situations.
Code: Select all
$ echo -e 'X\xa9X' > label.txt
$ convert label:@label.txt test.png
My result: X©X
This file is not valid UTF-8, and IM interprets it as Latin-1 or similar. It must be doing some autodetection of the encoding.
Code: Select all
$ echo -e 'X\xe4\xb8\x8eX' > label.txt
$ convert label:@label.txt test.png
My result: X?X
This is a CJK character, encoded in UTF-8. Since it was displayed as a single question mark instead of three garbage characters, I assume this is a limitation of the font that was used, and not a problem with interpreting the UTF-8 encoding.
Re: convert(1) command can't handle multibyte characters
Posted: 2013-07-17T09:57:34-07:00
by fmw42
gmr wrote:Any ideas on the issue. The issue is the same as Sonam had mentioned.
bash-3.2# /usr/sfw/bin/convert label:@text_UTF-8.txt out.png
convert: FreeType library is not available `/usr/openwin/lib/X11/fonts/TTbitmaps/Arial-Bold14.pcf.Z'.
convert: FreeType library is not available `/usr/openwin/lib/X11/fonts/TTbitmaps/Arial-Bold14.pcf.Z'.
convert: FreeType library is not available `/usr/openwin/lib/X11/fonts/TTbitmaps/Arial-Bold14.pcf.Z'.
convert: FreeType library is not available `/usr/openwin/lib/X11/fonts/TTbitmaps/Arial-Bold14.pcf.Z'.
convert: FreeType library is not available `/usr/openwin/lib/X11/fonts/TTbitmaps/Arial-Bold14.pcf.Z'.
convert: FreeType library is not available `/usr/openwin/lib/X11/fonts/TTbitmaps/Arial-Bold14.pcf.Z'.
bash-3.2# ls /usr/openwin/lib/X11/fonts/TTbitmaps/Arial-Bold14.pcf.Z
/usr/openwin/lib/X11/fonts/TTbitmaps/Arial-Bold14.pcf.Z
bash-3.2#
So the file exists on the system, even though the error says the freetype library is not available.
So to put a straight question, does imagemagick support multi-byte character conversion?
If yes, can I get pointers on what to look for regarding the issue?
Thanks
If freetype exists, it is not where IM expects to find it. Perhaps your PATH does not point to that location.
To check about IM, on current versions use
convert -version
and see if freetype is listed as delegates
On older systems, type
convert -list configure
look at the line starting with DELEGATES and see if it is listed there.
Re: convert(1) command can't handle multibyte characters
Posted: 2013-08-15T22:57:46-07:00
by gmr
The running version of imagemagick is 6.8.3-5. "convert -version" lists freetype in the delegates list, as below.
Features: DPC Modules
Delegates: bzlib fftw freetype jng jpeg lcms lzma openexr pango png ps tiff x xml zlib
I also tried the given examples in the previous update ... but I was not able to convert some of them. The copyright symbol was converted correctly. But none of the other characters were converted correctly.
Code: Select all
$ echo -e 'X\xa9X' > label.txt
$ convert label:@label.txt test.png
My result is also as expected : X©X. But, where as the following convert did not yield the result as expected. I got the conversion text as a question mark.
Code: Select all
$ echo -e 'X\xe2\x98\xbaX' > label.txt
$ convert label:@label.txt test.png
Any thoughts on where might be the issue ?? There was a mention of the fonts. How do I check on whether the available fonts are an issue?
Thanks for the help!
gmr!
Re: convert(1) command can't handle multibyte characters
Posted: 2013-08-16T10:04:08-07:00
by fmw42
convert label:@label.txt test.png
The text file must support UTF8.
Re: convert(1) command can't handle multibyte characters
Posted: 2013-08-16T10:24:51-07:00
by magick
And the font must support the Unicode character set such as Arial Unicode, and extended MS font.
Re: convert(1) command can't handle multibyte characters
Posted: 2013-08-16T11:09:35-07:00
by Jason S
Use the -font and -pointsize options to select a font that contains the characters you need. "convert -list font" will list the known fonts.
Re: convert(1) command can't handle multibyte characters
Posted: 2013-12-26T01:50:52-07:00
by gmr
Updating to have the closure remarks.
Thanks. Having explicitly pointing to the font file, did the trick.