Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeprecationWarning: ANTIALIAS is deprecated #5684

Closed
wRAR opened this issue Oct 20, 2022 · 11 comments · Fixed by #5692
Closed

DeprecationWarning: ANTIALIAS is deprecated #5684

wRAR opened this issue Oct 20, 2022 · 11 comments · Fixed by #5692

Comments

@wRAR
Copy link
Member

wRAR commented Oct 20, 2022

scrapy/pipelines/images.py:163: DeprecationWarning: ANTIALIAS is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.LANCZOS instead.
image.thumbnail(size, self._Image.ANTIALIAS)

This is deprecated since Pillow 9.1.0, released in April. We should check if Resampling.LANCZOS is already available in the earliest version we support (7.1.0 as far as I can see), and use it if it's available there. If it was added later, I think we need to decide how to proceed.

@iamkaushal
Copy link
Contributor

@wRAR I just checked Resampling.LANCZOS is not available in the Pillow 7.1.0.

How should we proceed?

@wRAR
Copy link
Member Author

wRAR commented Oct 20, 2022

@iamkaushal I see.
Probably use Resampling.LANCZOS if it's available, otherwise use whatever is available instead (assuming Image.LANCZOS is available on all suppported versions, I'd use it instead of Image.ANTIALIAS to make it clearer that the code does the same on all versions, as AFAICS Image.LANCZOS is the same as Image.ANTIALIAS).

@iamkaushal
Copy link
Contributor

Image.LANCZOS is not available since version 9.1.0 @wRAR

@wRAR
Copy link
Member Author

wRAR commented Oct 20, 2022

It's available, of course. But even if it wasn't, I don't see how it would prevent implementing what I wrote earlier.

@iamkaushal
Copy link
Contributor

Yes sorry I meant it is not available without warning. If replacing with Image.LANCZOS is fine for now, I would like to work on this issue.

@Gallaecio
Copy link
Member

I think we can just switch to the new name, it seems it has been available since Pillow 2.7.

@wRAR
Copy link
Member Author

wRAR commented Oct 20, 2022

Yes sorry I meant it is not available without warning.

But I said "use Resampling.LANCZOS if it's available".

I think we can just switch to the new name, it seems it has been available since Pillow 2.7.

It's only about Image.LANCZOS which is deprecated in favor of Image.Resampling.LANCZOS as well.

@Gallaecio
Copy link
Member

@iamkaushal If you are up for it, the strategy here would be to do something like:

try:
    LANCZOS = Image.Resampling.LANCZOS
except AttributeError:
    LANCZOS = Image.LANCZOS

And then use LANCZOS in Scrapy code.

I am not AttributeError is the actual exception raised, mind you.

@iamkaushal
Copy link
Contributor

iamkaushal commented Oct 21, 2022

@Gallaecio Thank you. Yes I would like to take this up.

But I said "use Resampling.LANCZOS if it's available".

@wRAR My bad, I got confused because Resampling.LANCZOS is not available in 7.1.0

I want to work on this based on the idea proposed by @Gallaecio

@Gallaecio @wRAR I am new to open source. Really appreciate your support. Thank you.

@wRAR
Copy link
Member Author

wRAR commented Oct 21, 2022

Please also add a comment which tells in which version was Image.Resampling.LANCZOS added, so that we can see if we can delete the try-except block when updating the minimum reqs for Pillow.

@iamkaushal
Copy link
Contributor

iamkaushal commented Oct 21, 2022

Sure, will do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants