Houdini has full python PIL module or it is minimal?

   3335   2   0
User Avatar
Member
7 posts
Joined: 10月 2013
Offline
Hi everyone,
I am trying to add a slate frame(company logo, artist data etc) just before the mplay preview.I am testing the pil module, comes with houdini itself.

For testing i was running below code from self tool.
from PIL import Image, ImageDraw, ImageFont
 
image = Image.open('C:\Users\sunlight\Desktop\Houdini3D_icon.png')
width, height = image.size
 
draw = ImageDraw.Draw(image)
text = "A watermark"
 
font = ImageFont.truetype('C:\Users\sunlight\Desktop\arial.ttf', 12)
textwidth, textheight = draw.textsize(text, font)
 
# calculate the x,y coordinates of the text
margin = 5
x = width - textwidth - margin
y = height - textheight - margin
 
# draw watermark in the bottom right corner
draw.text((x, y), text, font=font)
 
image.save('cats.png')

but it is giving me error
Traceback (most recent call last):
  File "tool_1", line 9, in <module>
  File "C:\PROGRA~1\SIDEEF~1\HOUDIN~1.736\python27\lib\site-packages\PIL\ImageFont.py", line 260, in truetype
    return FreeTypeFont(font, size, index, encoding)
  File "C:\PROGRA~1\SIDEEF~1\HOUDIN~1.736\python27\lib\site-packages\PIL\ImageFont.py", line 140, in __init__
    self.font = core.getfont(font, size, index, encoding)
  File "C:\PROGRA~1\SIDEEF~1\HOUDIN~1.736\python27\lib\site-packages\PIL\ImageFont.py", line 42, in __getattr__
    raise ImportError("The _imagingft C module is not installed")
ImportError: The _imagingft C module is not installed



If I run this code from my window python , its working.

Thanking you guys in advance, need help !!!!
Himanshu Solanki
------------------------
Houdini TD
User Avatar
スタッフ
586 posts
Joined: 5月 2014
Offline
It looks like the PIL library isn't being packaged properly in the Windows build of Houdini. The version of PIL that's shipped with Houdini is missing some of the PIL/FreeType libraries, which are needed to load in font files. I'll look into fixing that issue on our end.

In the mean time, it might be possible to use your non-Houdini version of PIL with Houdini by adding it to the Python module search path. For example, you can try doing the following at the top of your script:

# Insert the path to PIL on your system before other entries in the search path, to make sure it's picked up first
import sys
sys.path.insert(0, "path to your Windows PIL installation")

# Import PIL modules
from PIL import Image, ImageDraw, ImageFont
...

Note that this will only work if your system's version of PIL and its dependencies are compatible with the version of Python used by Houdini. I'm not sure if this will be the case.
User Avatar
スタッフ
586 posts
Joined: 5月 2014
Offline
This should now be fixed in the PIL module shipped with Houdini, in the latest build of 16.0 and 16.5.
  • Quick Links