SourceForge has been redesigned. Learn more.
Close

#26 WebP support

SVN
closed-fixed
nobody
webp (1)
8
2016-02-18
2013-09-19
Emery
No

Here is a a patch for WebP support. It requires Pillow rather than PIL.

The WebP makes for archives that are generally a third smaller.

1 Attachments

Discussion

  • Emery

    Emery - 2013-09-19

    I hope priority 8 means no big deal

     
  • Oddegamra

    Oddegamra - 2013-09-19

    Hm, it's a bit irritating that I cannot find any sort of version indicator that could be used to determine if if the user currently has PIL, or Pillow, installed. Even PIL.Image.VERSION is 1.1.7 instead of of 2.0.0. If possible, I'd like to keep backwards compatibility and only enable WebP processing is the user is actually running Pillow, instead of forcing him to use Pillow in order to use MComix.

     
  • Oddegamra

    Oddegamra - 2013-09-22

    Alright, guess the "best" way in this context to check for WebP support would be trying to import PIL.WebPImagePlugin and catch ImportError.

    There's still a bit missing, though. SUPPORTED_IMAGE_REGEX in constants is only used for files within archives. All other files are checked through image_tools.is_image_file, which relies completely on GTK to determine if the image is actually supported. Come to think of it, SUPPORTED_IMAGE_REGEX should probably be generated from this list as well, instead of using an arbitrary number of extensions.

     
  • seb morin

    seb morin - 2014-05-26

    To check if you've got PILLOW:
    hasattr(PIL,'PILLOW_VERSION')

    To check which webp version you've got with PILLOW:
    from PIL import _webp
    _webp.WebPDecoderVersion()

     
  • Benoit Pierre

    Benoit Pierre - 2015-12-03

    WebP is now supported when available (either gdk-pixbuf-webp is available when using GDK, or WebP support has been compiled in when using Pillow).

     
  • Benoit Pierre

    Benoit Pierre - 2015-12-03
    • status: open --> closed-fixed
     
  • Tomasz Golinski

    Tomasz Golinski - 2016-02-18

    At the moment webp support is rather well hidden ;) Mcomix defaults to gdk-pixbuf and gdk-pixbuf webp loader is far from common.

    I'm using Gentoo and in a typical scenario user has both Pillow and gdk-pixbuf installed while only Pillow supports webp. Since uninstalling gdk-pixbuf is not an option, user ends up with the choice of either modifying mcomix code or building gdk-pixbuf loader. I don't know what's the situation with other distros out there.

    It would be optimal to provide either command line option for choosing Pillow or gdk-pixbuf or an option in "Preferences". The optimal (and probably the hardest) way would be probably to fallback to Pillow when file type is not recognized.

     
  • Benoit Pierre

    Benoit Pierre - 2016-02-18

    I really don't want to mix-and-match loading some image formats with GdkPixbuf and others with Pillow. And adding an option to choose which one to choose whould further complexify MComix... Note also that the WebP support in previous versions of Pillow was simply put unusable, as it was leaking the decoded buffer.

     
    Last edit: Benoit Pierre 2016-02-18
  • Tomasz Golinski

    Tomasz Golinski - 2016-02-18

    Ok, I understand the reasons. So, I'll try to get gdk-pixbuf webp support into my distro :)

     
  • Benoit Pierre

    Benoit Pierre - 2016-02-18

    If you do want to switch to Pillow, it should be pretty easy, as that was the default on Windows until very recently, and the code is still here. You need at least version 2.5.0, and to apply this patch:

    diff --git i/mcomix/image_tools.py w/mcomix/image_tools.py
    index cb5751b..d5e7cb2 100644
    --- i/mcomix/image_tools.py
    +++ w/mcomix/image_tools.py
    @@ -29,7 +29,7 @@ if sys.platform == 'win32':
         # NOTE: Using False here should work fine for Windows, too.
         USE_PIL = False
     else:
    -    USE_PIL = False
    +    USE_PIL = True
    
     log.info('Using %s for loading images (versions: %s [%s], GDK [%s])',
              'PIL' if USE_PIL else 'GDK',
    
     

Log in to post a comment.