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

ZeroDivisionError when thumbnail is passed a 0x0 SVG #622

Open
gonzalodelgado opened this issue Aug 21, 2023 · 1 comment
Open

ZeroDivisionError when thumbnail is passed a 0x0 SVG #622

gonzalodelgado opened this issue Aug 21, 2023 · 1 comment
Labels

Comments

@gonzalodelgado
Copy link

Hi there, I'm getting a ZeroDivisionError when uploading an SVG using django-filer. The error is coming from easy_thumbnails' scale_and_crop processor, when computing the scale:

Traceback (most recent call last):
  File "[virtualenv-path]/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "[virtualenv-path]/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "[virtualenv-path]/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "[virtualenv-path]/lib/python3.8/site-packages/filer/admin/clipboardadmin.py", line 132, in ajax_upload
    thumbnail_180 = file_obj.file.get_thumbnail(
  File "[virtualenv-path]/lib/python3.8/site-packages/easy_thumbnails/files.py", line 508, in get_thumbnail
    thumbnail = self.generate_thumbnail(
  File "[virtualenv-path]/lib/python3.8/site-packages/easy_thumbnails/files.py", line 389, in generate_thumbnail
    thumbnail_image = engine.process_image(image, thumbnail_options,
  File "[virtualenv-path]/lib/python3.8/site-packages/easy_thumbnails/engine.py", line 35, in process_image
    image = processor(image, **processor_options)
  File "[virtualenv-path]/lib/python3.8/site-packages/filer/thumbnail_processors.py", line 52, in scale_and_crop_with_subject_location
    return processors.scale_and_crop(im, size, zoom=zoom, crop=crop,
  File "[virtualenv-path]/lib/python3.8/site-packages/easy_thumbnails/processors.py", line 177, in scale_and_crop
    scale = max(target_x / source_x, target_y / source_y)
ZeroDivisionError: float division by zero
@jrief jrief added the bug label Aug 23, 2023
@jrief
Copy link
Collaborator

jrief commented Aug 23, 2023

Thanks for reporting.

gonzalodelgado added a commit to gonzalodelgado/easy-thumbnails that referenced this issue Aug 28, 2023
Set X or Y scale to 1.0 when corresponding source size is 0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants