GAE Dev Server Output
WARNING 2018-05-16 10:29:06,169 blob_image.py:208] Serving resized images requires a working Python "PIL" module. The image is served without resizing.
When deployed to App Engine it all works fine and this catch is explained in Google's documentation...
Note: When running your app locally on the development server, you'll need to install PIL if you wish to use the image sizing options described in this page.
Well no big deal, just install PIL right? Unfortunately at the time of writing there was no compiled version available for macOS and for the system Python version I was running. This meant I had to do a bit more work.
First I made sure of the Python version...
Terminal
> python --version
Python 2.7.10
Alright, version 2.7, the only pre-compiled download I saw was for 2.5. I went ahead and got the source version of PIL 1.7. The following steps require Xcode and command line tools to be installed, I've already done this a long time ago, but here's a nice article that describes how to do it just in case. You will also need to make sure that XQuartz is installed before running any of the steps below.
I had a look at the README and got as far as the "If you're in a hurry" section...
--------------------------------------------------------------------
Build instructions (all platforms)
--------------------------------------------------------------------
For a list of changes in this release, see the CHANGES document.
0. If you're in a hurry, try this:
$ tar xvfz Imaging-1.1.7.tar.gz
$ cd Imaging-1.1.7
$ python setup.py install
Build instructions (all platforms)
--------------------------------------------------------------------
For a list of changes in this release, see the CHANGES document.
0. If you're in a hurry, try this:
$ tar xvfz Imaging-1.1.7.tar.gz
$ cd Imaging-1.1.7
$ python setup.py install
Unfortunately that caused the build to fail, doh!
Terminal
Imaging-1.1.7 > python setup.py install
...
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/tk.h:78:11: fatal error: 'X11/Xlib.h' file not found
# include <X11/Xlib.h>
No matter, this was not a big deal. All I had to do was tell make where to look for the X11 headers. Below were the commands I used to build and finally install PIL...
Terminal
export CFLAGS=-I/opt/X11/include
python setup.py build
sudo python setup.py install
That was all that was required. PIL installed correctly and after restarting the dev server I didn't see any more of the warnings about image resizing.
-i