DeprecationWarning but replacement doesn't work

Chris Green cl at isbd.net
Sat Feb 4 10:17:38 EST 2023


I am using Image from PIL and I'm getting a deprecation warning as
follows:-

/home/chris/bin/picShrink.py:80: DeprecationWarning: ANTIALIAS is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.LANCZOS instead.


The code is very simple:-

    ...
    ...
    from PIL import Image
    ...
    ...
        im = Image.open(srcFile)
        im.thumbnail(size, Image.ANTIALIAS)
        im.save(dstFile, "JPEG")


But if I change line 80 to:-

        im.thumbnail(size, Resampling.LANCZOS)

I simply get an error as follows:-

    picShrink.py
    Traceback (most recent call last):
      File "/home/chris/bin/picShrink.py", line 80, in <module>
        im.thumbnail(size, Resampling.LANCZOS)
    NameError: name 'Resampling' is not defined


So, presumably there's more I need to change.  Where can I find out what
I need to do?

-- 
Chris Green
·


More information about the Python-list mailing list