[Django] #29705: Runtimeerror while Django Image Field received some type of webp file

38 views
Skip to first unread message

Django

unread,
Aug 23, 2018, 1:25:07 AM8/23/18
to django-...@googlegroups.com
#29705: Runtimeerror while Django Image Field received some type of webp file
----------------------------------------+---------------------------
Reporter: Ji Qu | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: master
Severity: Normal | Keywords: image get
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+---------------------------
Hi,

This is my first time to report a bug for django-project, please feel free
to give me a hand if I have any non-standard workflow.

I have meet a "RuntimError" while trying to save a webp-image.

I have searched django tickets with following link but no similar ticket
found:

[https://code.djangoproject.com/search?ticket=on&q=webp+&page=6&noquickjump=1
search result]

I have made a **online project** to reproduce the "bug".

- [https://github.com/winkidney/django-webp-image-issue-case github-
repo]
- [https://travis-ci.org/winkidney/django-webp-image-issue-case travis-
ci]

Please follow this link to track how this bug happens and how it affects
my own sites.

A patch is being making to fix the possible "RuntimeError" while saving a
webp page.

For your information, I will also paste the code which could reproduce the
bug.

{{{
import os

from django.core.files.images import get_image_dimensions
import pytest


FILE_NAME = 'img.webp'

here = os.path.dirname(__file__)
file_path = os.path.join(here, FILE_NAME)


def test_webp_parse_error():
"""
Webp file from douban.com, displays in browser well,
can be opened by PIL but error occurs while use django parse.
"""
with pytest.raises(
RuntimeError,
) as info:
with open(file_path, 'rb') as fp:
get_image_dimensions(file_or_path=fp, close=True)
assert str(info.value) == 'could not create decoder object'


def test_the_working_way():
with open(file_path, "rb") as fp:
from PIL import Image
image = Image.open(fp)
print(image.size)
}}}

Please download the image with these links:
From douban:
[https://img3.doubanio.com/view/status/m/public/a606779b213ae14.webp]
From google: [https://developers.google.com/speed/webp/gallery?hl=zh-CN]
[https://www.gstatic.com/webp/gallery/4.sm.webp]

Python version:
Python 3.6.4

Kernel version:
Linux ubuntu 4.15.0-29-generic #31~16.04.1-Ubuntu SMP Wed Jul 18
08:54:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Version of libweb:

ii libwebp-dev:amd64 0.4.4-1
amd64 Lossy compression of digital photographic images.
ii libwebp5:amd64 0.4.4-1
amd64 Lossy compression of digital photographic images.
ii libwebpdemux1:amd64 0.4.4-1
amd64 Lossy compression of digital photographic images.
ii libwebpmux1:amd64 0.4.4-1
amd64 Lossy compression of digital photographic images.

When the error occurs:
While I try to save image with webp format, the error occurs.


PS: I don't know how to assign the bug to myself, is there any link or doc
for me to make my pull request?

--
Ticket URL: <https://code.djangoproject.com/ticket/29705>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 23, 2018, 1:25:27 AM8/23/18
to django-...@googlegroups.com
#29705: Runtimeerror while Django Image Field received some type of webp file
------------------------------+--------------------------------------
Reporter: Ji Qu | Owner: Ji Qu
Type: Bug | Status: assigned

Component: Core (Other) | Version: master
Severity: Normal | Resolution:

Keywords: image get | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by Ji Qu):

* status: new => assigned
* owner: nobody => Ji Qu


--
Ticket URL: <https://code.djangoproject.com/ticket/29705#comment:1>

Django

unread,
Aug 23, 2018, 1:26:25 AM8/23/18
to django-...@googlegroups.com
#29705: Runtimeerror while Django Image Field received some type of webp file
-------------------------------------+-------------------------------------

Reporter: Ji Qu | Owner: Ji Qu
Type: Bug | Status: assigned
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: image | Triage Stage:
get_image_dimensions | Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ji Qu):

* keywords: image get => image get_image_dimensions


--
Ticket URL: <https://code.djangoproject.com/ticket/29705#comment:2>

Django

unread,
Aug 23, 2018, 1:36:52 AM8/23/18
to django-...@googlegroups.com
#29705: RuntimeError while save webp file to Image-Field

-------------------------------------+-------------------------------------
Reporter: Ji Qu | Owner: Ji Qu
Type: Bug | Status: assigned
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: image | Triage Stage:
get_image_dimensions | Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Ji Qu:

Old description:

New description:

Hi,

[https://code.djangoproject.com/search?ticket=on&q=webp+&page=6&noquickjump=1
search result]

{{{
import os


FILE_NAME = 'img.webp'

Python version:
Python 3.6.4

Version of libweb:

--

--
Ticket URL: <https://code.djangoproject.com/ticket/29705#comment:3>

Django

unread,
Aug 23, 2018, 2:19:17 AM8/23/18
to django-...@googlegroups.com
#29705: RuntimeError while saving webp file to Image-Field

-------------------------------------+-------------------------------------
Reporter: Ji Qu | Owner: Ji Qu
Type: Bug | Status: assigned
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: image | Triage Stage:
get_image_dimensions | Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/29705#comment:4>

Django

unread,
Aug 23, 2018, 2:20:02 AM8/23/18
to django-...@googlegroups.com
#29705: RuntimeError while saving webp file to Image-Field
-------------------------------------+-------------------------------------
Reporter: Ji Qu | Owner: Ji Qu
Type: Bug | Status: assigned
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: image | Triage Stage:
get_image_dimensions | Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ji Qu):

* cc: Ji Qu (added)
* has_patch: 0 => 1


Comment:

The patch is here: [https://github.com/django/django/pull/10331]

--
Ticket URL: <https://code.djangoproject.com/ticket/29705#comment:5>

Django

unread,
Aug 23, 2018, 3:44:09 AM8/23/18
to django-...@googlegroups.com
#29705: RuntimeError while saving webp file to Image-Field
-------------------------------------+-------------------------------------
Reporter: Ji Qu | Owner: Ji Qu
Type: Bug | Status: assigned
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: image | Triage Stage: Accepted
get_image_dimensions |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* stage: Unreviewed => Accepted


Comment:

Hi Ji Qu.

Thanks for the report. Very well put together.

Looks reasonable.

--
Ticket URL: <https://code.djangoproject.com/ticket/29705#comment:6>

Django

unread,
Aug 23, 2018, 9:36:34 AM8/23/18
to django-...@googlegroups.com
#29705: RuntimeError while saving webp file to Image-Field
-------------------------------------+-------------------------------------
Reporter: Ji Qu | Owner: Ji Qu
Type: Bug | Status: closed

Component: Core (Other) | Version: master
Severity: Normal | Resolution: fixed

Keywords: image | Triage Stage: Accepted
get_image_dimensions |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"c69d40f94308d52243133def3b6be7ff403df6f1" c69d40f]:
{{{
#!CommitTicketReference repository=""
revision="c69d40f94308d52243133def3b6be7ff403df6f1"
Fixed #29705 -- Fixed ImageField RuntimeError crash for WebP files.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29705#comment:7>

Django

unread,
Aug 23, 2018, 9:54:32 AM8/23/18
to django-...@googlegroups.com
#29705: RuntimeError while saving webp file to ImageField

-------------------------------------+-------------------------------------
Reporter: Ji Qu | Owner: Ji Qu
Type: Bug | Status: closed
Component: Core (Other) | Version: master
Severity: Normal | Resolution: fixed
Keywords: image | Triage Stage: Accepted
get_image_dimensions |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/29705#comment:8>

Reply all
Reply to author
Forward
0 new messages