2016-06-17 18 views
1

私のpython-FotoBoxスクリプトは、スクリプトは次のような問題持っているRaspbianを実行している私のUbuntuのlabtopにも完璧に作業していて、ラズベリー・パイの上に持っている:Pythonの画像ライブラリ、ImageFont例外IOError

[email protected]:~/Desktop/FotoBox $ python PythonCollage_31.py 
    Traceback (most recent call last): 
     File "PythonCollage_31.py", line 49, in <module> 
     font = ImageFont.truetype("/usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS.ttf", 80, 0, 'unic') 
     File "/usr/lib/python2.7/dist-packages/PIL/ImageFont.py", line 240, in truetype 
     return FreeTypeFont(font, size, index, encoding) 
     File "/usr/lib/python2.7/dist-packages/PIL/ImageFont.py", line 137, in __init__ 
     self.font = core.getfont(font, size, index, encoding) 
    IOError: unknown file format 

私も試してみましたが他のコード行を使用してフォントオブジェクトを作成します。

font = ImageFont.truetype("/usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS.ttf", 80) 

ただし、同じ結果が得られます。

フォントを含むファイルが存在します。あなたの代わりに「」のあなたの規定パラメータ、使用「」の先頭に=エンコーディングを追加したり、削除した場合、だから、

ImageFont.truetype(file, size, encoding=value) 

[email protected]:~/Desktop/FotoBox $ ls -l /usr/share/fonts/truetype/msttcorefonts/ 
insgesamt 4 
-rw-r--r-- 1 root root 128 Jun 17 22:04 Comic_Sans_MS.ttf 

答えて

0

ImageFont.truetypeの正しい構文はこれです3番目のパラメータは、次のようになります。

ImageFont.truetype("/usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS.ttf", 80, 
encoding="unic") 

これは私のために働きます。

関連する問題