2016-06-17 5 views
1

나는 파이썬 FotoBox-스크립트 스크립트는 다음과 같은 문제를 가지고있다 Raspbian을 실행하는 내 우분투 labtop에 완벽하게 잘 작동하지만, 라스베리 파이에 있습니다파이썬 이미징 라이브러리, ImageFont IO 오류

[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에 대한 올바른 구문이 있습니다 세 번째 매개 변수는 다음과 같이 표시되어야합니다.

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

그리고 이것은 저에게 효과적입니다.

관련 문제