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

AttributeError when using pillow >=10.0 #256

Closed
max747 opened this issue Aug 2, 2023 · 0 comments
Closed

AttributeError when using pillow >=10.0 #256

max747 opened this issue Aug 2, 2023 · 0 comments

Comments

@max747
Copy link

max747 commented Aug 2, 2023

If pillow 10.0.0 or greater version is installed, django-markdownx raises AttributeError when uploading a large size image by drag & drop to a form that is related to the markdownx widget. This occurs when the image is resized.
https://github.com/neutronX/django-markdownx/blob/v4.0.2/markdownx/utils.py#L123-L124

PIL.Image.ANTIALIAS has been removed at pillow 10.0.0.
https://pillow.readthedocs.io/en/stable/releasenotes/10.0.0.html#constants

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/views/generic/base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/views/generic/base.py", line 143, in dispatch
    return handler(request, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/views/generic/edit.py", line 153, in post
    return self.form_valid(form)
  File "/usr/local/lib/python3.9/site-packages/markdownx/views.py", line 81, in form_valid
    image_path = form.save(commit=True)
  File "/usr/local/lib/python3.9/site-packages/markdownx/forms.py", line 61, in save
    image = self._process_raster(image, image_extension)
  File "/usr/local/lib/python3.9/site-packages/markdownx/forms.py", line 134, in _process_raster
    preped_image = scale_and_crop(image, **MARKDOWNX_IMAGE_MAX_SIZE)
  File "/usr/local/lib/python3.9/site-packages/markdownx/utils.py", line 124, in scale_and_crop
    im = _scale(im=im, x=source_x * scale, y=source_y * scale)
  File "/usr/local/lib/python3.9/site-packages/markdownx/utils.py", line 77, in _scale
    resample=Image.ANTIALIAS
AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'

Until django-markdownx supports pillow 10.0.0, it would be better to limit pillow version to <10.0 using requirements.txt.

environment

  • django-markdownx 4.0.2
  • pillow 10.0.0
@adi- adi- closed this as completed Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants