Note that I had to use PIL for various purposes PIL is a library for drawing (image generation, processing) in Python.
HomeBrew introduction method is omitted
Python was installed on the Mac (not dropped by HomeBrew)
python
brew install pil
ln -s /usr/local/Cellar/pil/1.1.7/lib/python2.7/site-packages/PIL /Library/Python/2.7/site-packages/PIL
Feeling like symlinking where the PIL is where the Python side is trying to use (nothing in that direction)? I couldn't do import image just by installing it.
Execution check Start python
python
>>> from PIL import Image,ImageDraw
>>> img = Image.new('RGB', (200,200),(255,255,255)) # 200*200 white background
>>> draw = ImageDraw.Draw(img)
>>> draw.line((20,50,150,80),fill=(255,0,0)) #Red straight line
>>> draw.line((150,150,20,200),fill=(0,255,0)) #Green straight line
>>> draw.text((40,80),'Hello',(0,0,0)) #Black letters
>>> img.save('test.jpg','JPEG') # test.Save as jpg
Execution result
Recommended Posts