Skip to content

WebPImagePlugin.py decodes webp in open()  #2483

Closed

Description

@christophegithubtts

What did you do?

Calling Image.open() on a webp file

What did you expect to happen?

The call should be quick

What actually happened?

open() for a webp image actually decodes the webp into rgb !
So open() for a webp image is much slower than open() for a png for instance

The implementation in WebPImagePlugin.py is not efficient at all.
open should call WebPGetInfo or WebPGetFeatures but not WebPDecode !

What versions of Pillow and Python are you using?

Latest pillow (4.1) and python 2.7

Activity

  1. wiredfool commented on Apr 11, 2017

    @wiredfool
    Member

    There is actually a pr languishing that totally rewrites webp support.

  2. hugovk commented on Apr 11, 2017

    @hugovk
    Member
  3. christophegithubtts commented on Apr 12, 2017

    @christophegithubtts
    Author

    wiredfool : do you mean pr #1122 has some problems and will not be checked in ?

  4. wiredfool commented on Apr 12, 2017

    @wiredfool
    Member

    No. I mean that there is a PR, and that it appeared to be a ground up rewrite which may or may not have the same issues as the current version of the webp plugin. IIRC, there was discussion around that PR, and then it went nowhere because it's a huge code drop that replaced existing functionality without ever discussing the differences between it and the current code.

  5. radarhere commented on Dec 28, 2018

    @radarhere
    Member

    #2761 being merged in on 6 Nov 2017 meant that WebPDecode is no longer called for newer versions of libwebp. Testing, if I force the legacy mode to be used, it is 424% of the time of PNG open. Testing the normal version of WebP open, I get 188% of the time of PNG open.

    Is that speed up sufficient for this issue to be closed?

  6. christophegithubtts commented on Jan 3, 2019

    @christophegithubtts
    Author

    That's better for sure
    I guess the following line
    self._decoder = _webp.WebPAnimDecoder(self.fp.read())
    is responsible for 88% additional time compared to png ?

    I let you close the ticket

  7. radarhere commented on Jan 4, 2019

    @radarhere
    Member

    No, self._decoder = _webp.WebPAnimDecoder(self.fp.read()) is only responsible for about 13% of the additional time compared to PNG.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions