django-cms / django-filer

File and Image Management Application for django
https://django-filer.readthedocs.io/
Other
1.78k stars 581 forks source link

UnidentifiedImageError when uploading an SVG #1310

Closed petrklus closed 1 year ago

petrklus commented 2 years ago

Steps to reproduce:

AJ_Digital_Camera

Tested on:

I can provide a link to a bare-bones project that reproduces the issue reliably.

petrklus commented 2 years ago
image

Request Method: GET
Request URL: https://filer-22-stage.us.aldryn.io/en/admin/filer/folder/1/list/

Django Version: 3.2.15
Python Version: 3.9.6
Installed Applications:
['aldryn_addons',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'aldryn_sso',
 'djangocms_admin_style',
 'django.contrib.admin',
 'django.contrib.staticfiles',
 'aldryn_django',
 'aldryn_sites',
 'cms',
 'aldryn_django_cms',
 'menus',
 'sekizai',
 'treebeard',
 'parler',
 'django.contrib.sitemaps',
 'compressor',
 'robots',
 'captcha',
 'django_select2',
 'filer.contrib.django_cms',
 'djangocms_text_ckeditor',
 'filer',
 'easy_thumbnails',
 'mptt',
 'polymorphic']
Installed Middleware:
['cms.middleware.utils.ApphookReloadMiddleware',
 'django.middleware.gzip.GZipMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'aldryn_sso.middleware.AccessControlMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.contrib.sites.middleware.CurrentSiteMiddleware',
 'aldryn_sites.middleware.SiteMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'cms.middleware.user.CurrentUserMiddleware',
 'cms.middleware.page.CurrentPageMiddleware',
 'cms.middleware.toolbar.ToolbarMiddleware',
 'cms.middleware.language.LanguageCookieMiddleware']

Template error:
In template /usr/local/lib/python3.9/site-packages/filer/templates/admin/filer/folder/directory_table.html, error at line 106
   cannot identify image file <_io.BytesIO object at 0x7faf6c2d7810>
   96 :                                 {% endif %}
   97 :                             </td>
   98 :                             <td class="column-icon">
   99 :                                 {% if is_popup and filer_admin_context.pick_file %}
   100 :                                     <a href="#" onclick="opener.dismissRelatedImageLookupPopup(window, {{ file.id|unlocalize }}, '{% file_icon_url file %}', '{{ file.label|escapejs }}'); return false;"
   101 :                                         title="{% trans 'Select this file' %}">
   102 :                                 {% elif has_change_permission %}
   103 :                                     <a href="{{ file.get_admin_change_url }}{% filer_admin_context_url_params %}"
   104 :                                             title="{% blocktrans with file.label as item_label %}Change '{{ item_label }}' details{% endblocktrans %}">
   105 :                                 {% endif %}
   106 :                                  {% file_icon file %} 
   107 :                                 {% if has_change_permission or is_popup and filer_admin_context.pick_file %}
   108 :                                     </a>
   109 :                                 {% endif %}
   110 :                             </td>
   111 :                             <td class="column-name">
   112 :                                 <div>
   113 :                                     <strong>
   114 :                                         {% if is_popup and filer_admin_context.pick_file %}
   115 :                                             <a href="#" onclick="opener.dismissRelatedImageLookupPopup(window, {{ file.id|unlocalize }}, '{% file_icon_url file %}', '{{ file.label|escapejs }}'); return false;"
   116 :                                                 title="{% trans 'Select this file' %}">

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/contrib/admin/sites.py", line 232, in inner
    return view(request, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/filer/admin/folderadmin.py", line 443, in directory_listing
    return render(request, self.directory_listing_template, context)
  File "/usr/local/lib/python3.9/site-packages/django/shortcuts.py", line 19, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "/usr/local/lib/python3.9/site-packages/django/template/loader.py", line 62, in render_to_string
    return template.render(context, request)
  File "/usr/local/lib/python3.9/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 170, in render
    return self._render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/loader_tags.py", line 195, in render
    return template.render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 172, in render
    return self._render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/defaulttags.py", line 214, in render
    nodelist.append(node.render_annotated(context))
  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/defaulttags.py", line 315, in render
    return nodelist.render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/defaulttags.py", line 519, in render
    return self.nodelist.render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/library.py", line 214, in render
    _dict = self.func(*resolved_args, **resolved_kwargs)
  File "/usr/local/lib/python3.9/site-packages/filer/templatetags/filer_admin_tags.py", line 120, in file_icon
    return file_icon_context(file, detail, width, height)
  File "/usr/local/lib/python3.9/site-packages/filer/templatetags/filer_admin_tags.py", line 94, in file_icon_context
    icon_url = thumbnailer.get_thumbnail(opts).url
  File "/usr/local/lib/python3.9/site-packages/easy_thumbnails/files.py", line 508, in get_thumbnail
    thumbnail = self.generate_thumbnail(
  File "/usr/local/lib/python3.9/site-packages/easy_thumbnails/files.py", line 382, in generate_thumbnail
    image = engine.generate_source_image(
  File "/usr/local/lib/python3.9/site-packages/easy_thumbnails/engine.py", line 112, in generate_source_image
    image = generator(source, **processor_options)
  File "/usr/local/lib/python3.9/site-packages/easy_thumbnails/source_generators.py", line 27, in pil_image
    image = Image.open(source)
  File "/usr/local/lib/python3.9/site-packages/PIL/Image.py", line 3147, in open
    raise UnidentifiedImageError(

Exception Type: UnidentifiedImageError at /en/admin/filer/folder/1/list/
Exception Value: cannot identify image file <_io.BytesIO object at 0x7faf6c2d7810>
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.