From: <mi...@us...> - 2012-05-03 10:55:40
|
Revision: 7422 http://docutils.svn.sourceforge.net/docutils/?rev=7422&view=rev Author: milde Date: 2012-05-03 10:55:30 +0000 (Thu, 03 May 2012) Log Message: ----------- odtwriter: import the PIL Image module via ``import PIL``. * Unify the PIL.Image import (images.py and the HTML writer changed already in Dec 2011, Pygments in May 2010). * starting with PIL 1.2, "PIL lives in the PIL namespace only" (http://mail.python.org/pipermail/image-sig/2011-January/006650.html) Modified Paths: -------------- trunk/docutils/HISTORY.txt trunk/docutils/docutils/writers/odf_odt/__init__.py Modified: trunk/docutils/HISTORY.txt =================================================================== --- trunk/docutils/HISTORY.txt 2012-05-03 06:37:16 UTC (rev 7421) +++ trunk/docutils/HISTORY.txt 2012-05-03 10:55:30 UTC (rev 7422) @@ -25,8 +25,12 @@ - New reStructuredText "code" role and directive and "code" option of the "include" directive with syntax highlighting by Pygments_. - Fix parse_option_marker for option arguments containing ``=``. + - Fix [ 2993756 ]: import Python Imaging Library's Image module + via ``import PIL`` as starting with PIL 1.2, + "PIL lives in the PIL namespace only" (announcement__). .. _Pygments: http://pygments.org/ +__ http://mail.python.org/pipermail/image-sig/2011-January/006650.html * setup.py Modified: trunk/docutils/docutils/writers/odf_odt/__init__.py =================================================================== --- trunk/docutils/docutils/writers/odf_odt/__init__.py 2012-05-03 06:37:16 UTC (rev 7421) +++ trunk/docutils/docutils/writers/odf_odt/__init__.py 2012-05-03 10:55:30 UTC (rev 7422) @@ -64,12 +64,15 @@ except ImportError, exp: pygments = None -# -# Is the PIL imaging library installed? -try: - import Image -except ImportError, exp: - Image = None +try: # check for the Python Imaging Library + import PIL +except ImportError: + try: # sometimes PIL modules are put in PYTHONPATH's root + import Image + class PIL(object): pass # dummy wrapper + PIL.Image = Image + except ImportError: + PIL = None ## import warnings ## warnings.warn('importing IPShellEmbed', UserWarning) @@ -2123,9 +2126,9 @@ height = self.get_image_width_height(node, 'height') dpi = (72, 72) - if Image is not None and source in self.image_dict: + if PIL is not None and source in self.image_dict: filename, destination = self.image_dict[source] - imageobj = Image.open(filename, 'r') + imageobj = PIL.Image.open(filename, 'r') dpi = imageobj.info.get('dpi', dpi) # dpi information can be (xdpi, ydpi) or xydpi try: iter(dpi) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |