Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 18 May 2019 11:15:00 +0000 (UTC)
From:      Kai Knoblich <kai@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r501950 - in head/graphics/py-mcomix: . files
Message-ID:  <201905181115.x4IBF0fk036684@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kai
Date: Sat May 18 11:15:00 2019
New Revision: 501950
URL: https://svnweb.freebsd.org/changeset/ports/501950

Log:
  graphics/py-mcomix: Fix runtime with graphics/py-pillow 6.0
  
  * Prevent runtime breakage when graphics/py-pillow is updated to 6.0 where
    the deprecated constant "Image.VERSION" is no longer available. [1]
  
  * Add a workaround for the behavior of the "_getexif" function that is still
    buggy with PNG files that contain EXIF meta data. [2]
  
  Also while I'm here:
  * Add "gnome" to USES as using USE_GNOME alone is deprecated.
  
  PR:		237887, 237426 (related)
  Approved by:	ashish (maintainer)
  Obtained from:	upstream [1], https://github.com/multiSnow/mcomix3/issues/76 [2]

Added:
  head/graphics/py-mcomix/files/
  head/graphics/py-mcomix/files/patch-mcomix_image__tools.py   (contents, props changed)
  head/graphics/py-mcomix/files/patch-mcomix_run.py   (contents, props changed)
Modified:
  head/graphics/py-mcomix/Makefile

Modified: head/graphics/py-mcomix/Makefile
==============================================================================
--- head/graphics/py-mcomix/Makefile	Sat May 18 10:46:07 2019	(r501949)
+++ head/graphics/py-mcomix/Makefile	Sat May 18 11:15:00 2019	(r501950)
@@ -3,7 +3,7 @@
 
 PORTNAME=	mcomix
 PORTVERSION=	1.2.1
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	graphics
 MASTER_SITES=	SF/${PORTNAME}/MComix-${PORTVERSION}
 PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
@@ -14,10 +14,10 @@ COMMENT=	GTK2 comic book viewer
 LICENSE=	GPLv2
 LICENSE_FILE=	${WRKSRC}/COPYING
 
-BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}pillow>0:graphics/py-pillow@${PY_FLAVOR}
+BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}pillow>=5.2.0:graphics/py-pillow@${PY_FLAVOR}
 RUN_DEPENDS:=	${BUILD_DEPENDS}
 
-USES=		python:2.7 tar:bzip2
+USES=		gnome python:2.7 tar:bzip2
 USE_GNOME=	pygtk2
 USE_PYTHON=	autoplist distutils
 

Added: head/graphics/py-mcomix/files/patch-mcomix_image__tools.py
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/graphics/py-mcomix/files/patch-mcomix_image__tools.py	Sat May 18 11:15:00 2019	(r501950)
@@ -0,0 +1,115 @@
+--- mcomix/image_tools.py.orig	2016-02-12 18:51:58 UTC
++++ mcomix/image_tools.py
+@@ -9,7 +9,6 @@ import gtk
+ from PIL import Image
+ from PIL import ImageEnhance
+ from PIL import ImageOps
+-from PIL.JpegImagePlugin import _getexif
+ try:
+     from PIL import PILLOW_VERSION
+     PIL_VERSION = ('Pillow', PILLOW_VERSION)
+@@ -51,7 +50,38 @@ assert MISSING_IMAGE_ICON
+ GTK_GDK_COLOR_BLACK = gtk.gdk.color_parse('black')
+ GTK_GDK_COLOR_WHITE = gtk.gdk.color_parse('white')
+ 
++def _getexif(im):
++    exif={}
++    try:
++        exif.update(im.getexif())
++    except AttributeError:
++        pass
++    if exif:
++        return exif
+ 
++    # Exif of PNG is still buggy in Pillow 6.0.0
++    try:
++        l1,l2,size,lines=im.info.get('Raw profile type exif').splitlines()
++        if l2!='exif':
++            # Not valid Exif data.
++            return {}
++        size=int(size)
++        data=binascii.unhexlify(''.join(lines))
++        if len(data)!=size:
++            # Size not match.
++            return {}
++        im.info['exif']=data
++    except:
++        # Not valid Exif data.
++        return {}
++
++    # load Exif again
++    try:
++        exif.update(im.getexif())
++    except AttributeError:
++        pass
++    return exif
++
+ def rotate_pixbuf(src, rotation):
+     rotation %= 360
+     if 0 == rotation:
+@@ -300,14 +330,7 @@ def pil_to_pixbuf(im, keep_orientation=False):
+     )
+     if keep_orientation:
+         # Keep orientation metadata.
+-        orientation = None
+-        exif = im.info.get('exif')
+-        if exif is not None:
+-            exif = _getexif(im)
+-            orientation = exif.get(274, None)
+-        if orientation is None:
+-            # Maybe it's a PNG? Try alternative method.
+-            orientation = _get_png_implied_rotation(im)
++        orientation = _getexit(im).get(274, None)
+         if orientation is not None:
+             setattr(pixbuf, 'orientation', str(orientation))
+     return pixbuf
+@@ -385,39 +408,6 @@ def enhance(pixbuf, brightness=1.0, contrast=1.0, satu
+         im = ImageEnhance.Sharpness(im).enhance(sharpness)
+     return pil_to_pixbuf(im)
+ 
+-def _get_png_implied_rotation(pixbuf_or_image):
+-    """Same as <get_implied_rotation> for PNG files.
+-
+-    Lookup for Exif data in the tEXt chunk.
+-    """
+-    if isinstance(pixbuf_or_image, gtk.gdk.Pixbuf):
+-        exif = pixbuf_or_image.get_option('tEXt::Raw profile type exif')
+-    elif isinstance(pixbuf_or_image, Image.Image):
+-        exif = pixbuf_or_image.info.get('Raw profile type exif')
+-    else:
+-        raise ValueError()
+-    if exif is None:
+-        return None
+-    exif = exif.split('\n')
+-    if len(exif) < 4 or 'exif' != exif[1]:
+-        # Not valid Exif data.
+-        return None
+-    size = int(exif[2])
+-    try:
+-        data = binascii.unhexlify(''.join(exif[3:]))
+-    except TypeError:
+-        # Not valid hexadecimal content.
+-        return None
+-    if size != len(data):
+-        # Sizes should match.
+-        return None
+-    im = namedtuple('FakeImage', 'info')({ 'exif': data })
+-    exif = _getexif(im)
+-    orientation = exif.get(274, None)
+-    if orientation is not None:
+-        orientation = str(orientation)
+-    return orientation
+-
+ def get_implied_rotation(pixbuf):
+     """Return the implied rotation in degrees: 0, 90, 180, or 270.
+ 
+@@ -429,9 +419,6 @@ def get_implied_rotation(pixbuf):
+     orientation = getattr(pixbuf, 'orientation', None)
+     if orientation is None:
+         orientation = pixbuf.get_option('orientation')
+-    if orientation is None:
+-        # Maybe it's a PNG? Try alternative method.
+-        orientation = _get_png_implied_rotation(pixbuf)
+     if orientation == '3':
+         return 180
+     elif orientation == '6':

Added: head/graphics/py-mcomix/files/patch-mcomix_run.py
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/graphics/py-mcomix/files/patch-mcomix_run.py	Sat May 18 11:15:00 2019	(r501950)
@@ -0,0 +1,15 @@
+--- mcomix/run.py.orig	2016-02-12 18:52:12 UTC
++++ mcomix/run.py
+@@ -203,7 +203,11 @@ def run():
+ 
+     try:
+         import PIL.Image
+-        assert PIL.Image.VERSION >= '1.1.5'
++        try:
++            assert PIL.Image.VERSION >= '1.1.5'
++        except AttributeError:
++            # Field VERSION deprecated in Pillow 5.2.0 and dropped in 6.0.0
++            assert PIL.__version__ >= '5.2.0'
+ 
+     except AssertionError:
+         log.error( _("You don't have the required version of the Python Imaging"), end=' ')



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905181115.x4IBF0fk036684>