Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Change Image import to support Pillow #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rolisz
Copy link

@rolisz rolisz commented Dec 14, 2013

PIL is no longer actively developed, but Pillow is an almost drop-in replacement. It requires only that the Image module be imported from the PIL namespace and not from the global one

PIL is no longer actively developed, but Pillow is an almost drop-in replacement. It requires only that the Image module be imported from the PIL namespace and not from the global one
@gcq
Copy link
Contributor

gcq commented Dec 14, 2013

I dig this 👍

But Pillow is not that extended. Should be changed to try Pillow and if it fails, use PIL.

Also update error messages

@chriskiehl
Copy link
Owner

Spot on, gcq. Try pillow, fall back to PIL, if both fail, raise the ImportError.

@rolisz
Copy link
Author

rolisz commented Dec 14, 2013

I have 64 bit Python installed and I couldn't find a PIL for 64 bits. When I tried with the 32 bit one, it crashed, but only after getting imported with

from PIL import Image

So there is no need for a fallback, because Python automatically uses the one that is installed. I think the only reason why this change is necessary is because PIL is doing some import magic, setting itself up in the global namespace (which is not a good practice), while Pillow uses only the PIL namespace.

@gcq
Copy link
Contributor

gcq commented Dec 14, 2013

Oh i understand now, i thought that PIL installed the Image module along the PIL module, but turns out it doesn't.

If thats correct, the only thing remaining to change is the error message, to something along the lines of:

"Need to have PIL or Pillow installed"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants