2015-09-30 13:38:51 +03:00
|
|
|
Porting
|
|
|
|
=======
|
|
|
|
|
|
|
|
**Porting existing PIL-based code to Pillow**
|
2013-10-09 04:13:06 +04:00
|
|
|
|
2020-02-05 13:06:09 +03:00
|
|
|
Pillow is a functional drop-in replacement for the Python Imaging Library.
|
|
|
|
|
|
|
|
PIL is Python 2 only. Pillow dropped support for Python 2 in Pillow
|
|
|
|
7.0. So if you would like to run the latest version of Pillow, you will first
|
|
|
|
and foremost need to port your code from Python 2 to 3.
|
|
|
|
|
|
|
|
To run your existing PIL-compatible code with Pillow, it needs to be modified
|
|
|
|
to import the ``Image`` module from the ``PIL`` namespace *instead* of the
|
2013-10-09 04:13:06 +04:00
|
|
|
global namespace. Change this::
|
|
|
|
|
|
|
|
import Image
|
|
|
|
|
|
|
|
to this::
|
|
|
|
|
|
|
|
from PIL import Image
|
|
|
|
|
2020-07-09 20:48:58 +03:00
|
|
|
The :py:mod:`PIL._imaging` module has been moved to :py:mod:`PIL.Image.core`.
|
|
|
|
You can now import it like this::
|
2013-10-09 04:13:06 +04:00
|
|
|
|
|
|
|
from PIL.Image import core as _imaging
|
2013-11-13 11:08:47 +04:00
|
|
|
|
2014-01-19 20:52:21 +04:00
|
|
|
The image plugin loading mechanism has changed. Pillow no longer
|
2013-11-13 11:08:47 +04:00
|
|
|
automatically imports any file in the Python path with a name ending
|
|
|
|
in :file:`ImagePlugin.py`. You will need to import your image plugin
|
|
|
|
manually.
|
|
|
|
|
2014-11-19 22:41:46 +03:00
|
|
|
Pillow will raise an exception if the core extension can't be loaded
|
|
|
|
for any reason, including a version mismatch between the Python and
|
|
|
|
extension code. Previously PIL allowed Python only code to run if the
|
|
|
|
core extension was not available.
|