14

I am facing an image processing task, and I'm using Python 3.2 (on a 64-bit Windows system). All my searches for image processing libraries have come up with are libraries for older versions of Python (most notably PIL, whose current version - 1.1.7 - supports Python 2.7). Does anyone know of an image processing library for Python 3?

By the way, I do not need fancy transformations and heavy stuff. All I need is to open a JPG file and get the image as an RGB-value matrix/list.

Any help will be most appreciated!

Tom
  • 4,910
  • 5
  • 33
  • 48

2 Answers2

5

The world is changing and everyone seem to be moving to a brand new library: Pillow. It is a drop-in replacement for PIL but it is alive and does support Python 3.

R Kiselev
  • 1,124
  • 1
  • 9
  • 18
kirelagin
  • 13,248
  • 2
  • 42
  • 57
5

You can get a source version of PIL which will compile on python3.1 here:

https://github.com/sloonz/pil-py3k

also binary installer for 3.2 and 64-bit windows here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pil

ref: Image library for Python 3

Community
  • 1
  • 1
so12311
  • 4,179
  • 1
  • 29
  • 37
  • @zephyr: Thank you very much! I installed the appropriate version, but there seems to be a bug there which I don't really understand: when I try to open an image file I get the message "ValueError: Attempted relative import in non-package". From my search it seems this is caused by differences in the way imports work in Python 2 and 3 (even though I did specifically download the binary installer for my Python 3.2). Any ideas how to get around that? – Tom Jun 01 '11 at 00:03
  • Hi Tom, can you post the exact commands and error that you get? I didn't try the installer as I'm on linux, but I was able to compile the source package and load a jpg. – so12311 Jun 01 '11 at 00:25
  • 1
    @tom yep, I get the same error as you on windows (vista, clean install of python3.2 64bit and PIL with the binary installer.) This is a horrible hack, but I was able to get it to work by replacing all the source files in C:/Python32/Lib/site-packages/PIL/ with the versions from the github link. If you compare them the github versions have a lot of for "from . import ..." statements replaced by "import ..." – so12311 Jun 01 '11 at 01:46
  • @zephyr: Thanks - it seems to work perfectly! By the way, the version on github is 1.1.6, whereas I had installed 1.1.7. Do you think that could cause some clashes? (As I said, so far it's been working perfectly, but I'm asking just in case.) – Tom Jun 01 '11 at 11:30
  • @tom it wouldn't surprise me at all if you encountered some clashes, I think the best thing to do would be to compile from the github source if you don't need any features from 1.1.7. – so12311 Jun 01 '11 at 11:58
  • 1
    On Python 3, use `from PIL import Image` instead of `import Image`, which is deprecated. – cgohlke Jun 23 '11 at 17:19