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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.pyindex 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 = Truelog.info('Using %s for loading images (versions: %s [%s], GDK [%s])',
'PIL' if USE_PIL else 'GDK',
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I hope priority 8 means no big deal
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.
Alright, guess the "best" way in this context to check for WebP support would be trying to import
PIL.WebPImagePluginand catch ImportError.There's still a bit missing, though.
SUPPORTED_IMAGE_REGEXinconstantsis only used for files within archives. All other files are checked throughimage_tools.is_image_file, which relies completely on GTK to determine if the image is actually supported. Come to think of it,SUPPORTED_IMAGE_REGEXshould probably be generated from this list as well, instead of using an arbitrary number of extensions.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()
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).
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.
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
Ok, I understand the reasons. So, I'll try to get gdk-pixbuf webp support into my distro :)
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: