Bug#1047864: impressive: Crashes at startup: «module 'PIL.Image' has no attribute 'ANTIALIAS'»

2023-08-15 Thread Gunnar Wolf
Package: impressive
Version: 0.13.1-1
Followup-For: Bug #1047864

Checking the online documentation of Pillow (the fork of PIL that Debian ships),
the ANTIALIAS method has been renamed as LANCZOS:

https://pillow.readthedocs.io/en/stable/releasenotes/2.7.0.html

Antialias renamed to Lanczos

A new LANCZOS constant was added instead of ANTIALIAS.

When ANTIALIAS was initially added, it was the only high-quality filter
based on convolutions. It’s name was supposed to reflect this. Starting from
Pillow 2.7.0 all resize method are based on convolutions. All of them are
antialias from now on. And the real name of the ANTIALIAS filter is Lanczos
filter.

The ANTIALIAS constant is left for backward compatibility and is an alias
for LANCZOS.

This relates to a very old version (2.7.0 is from 2015)... I don't know the
actual details as to when and why this backward compatibility alias was dropped,
but it just is not provided anymore.

I prepared the patch I'm attaching to this mail and tested it (it works
correctly); I'm rebuilding and uploading a NMU for 7 days.

-- System Information:
Debian Release: trixie/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.1.0-1-amd64 (SMP w/8 CPU threads; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages impressive depends on:
ii  mupdf-tools 1.22.2+ds1-1
ii  poppler-utils   22.12.0-2+b1
ii  python3 3.11.4-5+b1
ii  python3-pil 10.0.0-1
ii  python3-pygame  2.5.0-2

Versions of packages impressive recommends:
ii  ffmpeg 7:6.0-5
ii  mplayer2:1.5+svn38423-2+b1
ii  perl   5.36.0-7
ii  xdg-utils  1.1.3-4.1

Versions of packages impressive suggests:
ii  ghostscript   10.01.2~dfsg-1
pn  latex-beamer  
pn  pdftk 

-- no debconf information
diff --git a/impressive.py b/impressive.py
index 993dcee..9eb564c 100644
--- a/impressive.py
+++ b/impressive.py
@@ -2076,7 +2076,7 @@ class WipeClouds(Wipe):
 img = ImageOps.equalize(ImageOps.autocontrast(img))
 for i in range(self.blur):
 img = img.filter(ImageFilter.BLUR)
-img = img.crop((border, border, img.size[0] - 2 * border, img.size[1] 
- 2 * border)).resize((self.rx, self.ry), Image.ANTIALIAS)
+img = img.crop((border, border, img.size[0] - 2 * border, img.size[1] 
- 2 * border)).resize((self.rx, self.ry), Image.LANCZOS)
 return img2str(img)
 class WipeBrightness1(Wipe):
 """wipe based on the current slide's brightness"""
@@ -3505,16 +3505,16 @@ def RenderPDF(page, MayAdjustResolution, ZoomMode):
 # downsample a supersampled image
 if Supersample and not(ZoomMode):
 img = img.resize((int(float(out[0]) / Supersample + 0.5),
-  int(float(out[1]) / Supersample + 0.5)), 
Image.ANTIALIAS)
+  int(float(out[1]) / Supersample + 0.5)), 
Image.LANCZOS)
 parscale = False  # don't scale again
 
 # perform PAR scaling (required for pdftoppm which doesn't support 
different
 # dpi for horizontal and vertical)
 if parscale:
 if PAR > 1.0:
-img = img.resize((int(img.size[0] / PAR + 0.5), img.size[1]), 
Image.ANTIALIAS)
+img = img.resize((int(img.size[0] / PAR + 0.5), img.size[1]), 
Image.LANCZOS)
 else:
-img = img.resize((img.size[0], int(img.size[1] * PAR + 0.5)), 
Image.ANTIALIAS)
+img = img.resize((img.size[0], int(img.size[1] * PAR + 0.5)), 
Image.LANCZOS)
 
 # crop the overscan (if present)
 if Overscan:
@@ -3567,7 +3567,7 @@ def LoadImage(page, zoom=False, img=None):
 if newsize > img.size:
 filter = Image.BICUBIC
 else:
-filter = Image.ANTIALIAS
+filter = Image.LANCZOS
 return img.resize(newsize, filter)
 
 
@@ -3703,7 +3703,7 @@ def PageImage(page, ZoomMode=False, RenderMode=False):
 sy = OverviewCellY - 2 * OverviewBorder
 if HighQualityOverview:
 t0 = time.time()
-img.thumbnail((sx, sy), Image.ANTIALIAS)
+img.thumbnail((sx, sy), Image.LANCZOS)
 if (time.time() - t0) > 0.5:
 print("Note: Your system seems to be quite slow; 
falling back to a faster,", file=sys.stderr)
 print("  but slightly lower-quality overview page 
rendering mode", file=sys.stderr)
@@ -6409,7 +6409,7 @@ def main():
 if (dummy.size[0] > maxsize[0]) or (dummy.size[1] > maxsize[1]):
 size = ZoomToFit(dummy.size, maxsize, force_int=True)
 if min(size) > 0:
-dummy.thumbnail(size, Image.ANTIALIAS)
+dummy.thumbnail(size, Image.LANCZOS)
 else:
 dummy = None
 if dummy:


Bug#1047864: impressive: Crashes at startup: «module 'PIL.Image' has no attribute 'ANTIALIAS'»

2023-08-13 Thread Gunnar Wolf
Package: impressive
Version: 0.13.1-1
Severity: grave
Justification: renders package unusable

Hello again,

I have stumbled upon a new bug that affects impressive :-(

When starting up, I see the logo screen, but immediately afterwards, impressive
crashes with the following:

$ impressive test.pdf 
Welcome to Impressive version 0.13.1
Platform library: [pygame-unix] Python 3.11.4 / PyGame 2.5.0 / SDL 2.28.1
Detected screen size: 3840x2160 pixels
PDF renderer: MuPDF 1.4 or newer
OpenGL renderer: Mesa Intel(R) UHD Graphics 600 (GLK 2)
Your version of PIL is too old or incomplete, disabling OSD.
warning: ICC support is not available
warning: ICC support is not available


===
OOPS! Impressive crashed!
This shouldn't happen. Please report this incident to the author, including 
the
full output of the program, particularly the following lines. If possible,
please also send the input files you used.

Impressive version: 0.13.1
Python version: 3.11.4 (main, Jun 7 2023, 10:13:09) [GCC 12.2.0]
Impressive platform: pygame-unix
PyGame version: 2.5.0
SDL version: 2.28.1
PIL version: Pillow 10.0.0
PDF renderer: MuPDF 1.4 or newer
OpenGL vendor: Intel
OpenGL renderer: Mesa Intel(R) UHD Graphics 600 (GLK 2)
OpenGL version: 4.6 (Compatibility Profile) Mesa 23.1.4-1
Operating system: Linux 6.4.0-1-amd64 (x86_64)
Linux distribution: Debian GNU/Linux trixie/sid
Command line: /usr/bin/impressive test.pdf
Traceback (most recent call last):
  File "/usr/bin/impressive", line 6569, in run_main
main()
  File "/usr/bin/impressive", line 6486, in main
RenderPage(Pcurrent, Tcurrent)
  File "/usr/bin/impressive", line 3741, in RenderPage
gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGB, TexWidth, TexHeight, 0, gl.RGB, 
gl.UNSIGNED_BYTE, PageImage(page))

  ^^^
  File "/usr/bin/impressive", line 3706, in PageImage
img.thumbnail((sx, sy), Image.ANTIALIAS)
^^^
AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'
$ 

I suppose this comes as a change in python3-pil's API. I got impressive to work
again by very simplisticly substituting Image.ANTIALIAS in /usr/bin/impressive,
but of course, I'm sure there are better ways to patch this issue :-)

-- System Information:
Debian Release: trixie/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.1.0-1-amd64 (SMP w/8 CPU threads; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages impressive depends on:
ii  mupdf-tools 1.22.2+ds1-1
ii  poppler-utils   22.12.0-2+b1
ii  python3 3.11.4-5
ii  python3-pil 10.0.0-1
ii  python3-pygame  2.5.0-1

Versions of packages impressive recommends:
ii  ffmpeg 7:6.0-5
ii  mplayer2:1.5+svn38423-2+b1
ii  perl   5.36.0-7
ii  xdg-utils  1.1.3-4.1

Versions of packages impressive suggests:
ii  ghostscript   10.01.2~dfsg-1
pn  latex-beamer  
pn  pdftk 

-- no debconf information