diff --git a/README.md b/README.md index 5438c3b..d8c8184 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,8 @@ Python 3.6+ installation. We try to keep the external dependencies at a minimum, in order to keep compatibility with different platforms, including Pythonista on iOS. At this moment, we require: - - Pillow>=5.1.0 - - piexif>=1.1.2 + - Pillow>=6.2.2 + - piexif>=1.1.3 The easiest way to install it in a single step, including any dependencies, is by using this command: @@ -35,11 +35,6 @@ by using this command: pip3 install pillow optimize-images ``` -However, if you are on a Mac with Python 3.6 and macOS X 10.11 El Capitan or -earlier, you should use Pillow 5.0.0 instead (use instead: -`pip3 install pillow==5.0.0 optimize-images`). In case you have already -migrated to Python 3.7, you should be fine with Pillow 5.1.0 or later. - If you are able to swap Pillow with the faster version [Pillow-SIMD](https://github.com/uploadcare/pillow-simd), you should be able to get a considerably faster speed. For that reason, we provide, as a diff --git a/changelog.txt b/changelog.txt index 8a93ad3..d42d87b 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,11 +3,18 @@ Version history: ================ +--- +v.1.3.5 - 07-04-2020 + * Fixed a small bug in unsupported image format treatment. + * Added experimental support for MPO images, which are now treated as JPEG + image files (if multiple pictures are present in one MPO file, only the first + one will be processed). --- v.1.3.4 - 19-02-2020 * Ignore unsupported image formats (contributed by Petro (liashchynskyi@GitHub). - * Added brief instructions (and a script for macOS) for Pillow-SIMD installation, as a faster alternative to Pillow. + * Added brief instructions (and a script for macOS) for Pillow-SIMD + installation, as a faster alternative to Pillow. --- v.1.3.3 - 06-08-2019 diff --git a/docs/docs_EN.md b/docs/docs_EN.md index c40c738..3129bbb 100644 --- a/docs/docs_EN.md +++ b/docs/docs_EN.md @@ -50,8 +50,8 @@ Python 3.6+ installation. We try to keep the external dependencies at a minimum, in order to keep compatibility with different platforms, including Pythonista on iOS. At this moment, we require: - - Pillow>=5.1.0 - - piexif==1.0.13 + - Pillow>=6.2.2 + - piexif==1.1.3 The easiest way to install it in a single step, including any dependencies, is by using this command: @@ -60,11 +60,6 @@ by using this command: pip3 install pillow optimize-images ``` -However, if you are on a Mac with Python 3.6 and macOS X 10.11 El Capitan or -earlier, you should use Pillow 5.0.0 instead (use instead: -`pip3 install pillow==5.0.0 optimize-images`). In case you have already -migrated to Python 3.7, you should be fine with Pillow 5.1.0 or later. - If you are able to swap Pillow with the faster version [Pillow-SIMD](https://github.com/uploadcare/pillow-simd), you should be able to get a considerably faster speed. For that reason, we provide, as a @@ -180,6 +175,10 @@ choose to reduce the number of colors using an adaptive palette. Be aware that by using this option image quality may be affected in a very noticeable way. +Since version 1.3.5, Optimize Images also offers experimental support for MPO +images, which are now treated as single picture JPEG image files (if multiple +pictures are present in one MPO file, only the first one will be processed). + ### DISCLAIMER **Please note that the operation is done DESTRUCTIVELY, by replacing the diff --git a/docs/docs_PT.md b/docs/docs_PT.md index 41b4175..6d18ed0 100644 --- a/docs/docs_PT.md +++ b/docs/docs_PT.md @@ -52,8 +52,8 @@ superior. Procuramos manter no mínimo as dependências externas, de modo a manter a compatibilidade com diferentes plataformas, incluindo Pythonista em iOS. Neste momento, requer: - - Pillow==5.1.0 - - piexif==1.0.13 + - Pillow==6.2.2 + - piexif==1.1.3 A forma mais simples de instalar num único passo esta aplicação, incluindo quaisquer requisitos, é através deste comando: @@ -62,11 +62,6 @@ quaisquer requisitos, é através deste comando: pip3 install pillow optimize-images ``` -Nota: Se está a utilizar um Mac com Python 3.6 e macOS X 10.11 El Capitan ou -anterior, deverá usar antes a versão Pillow 5.0.0. No caso de já ter migrado -para Python 3.7, não deverá ter problemas com o Pillow 5.1.0 ou mesmo uma -versão mais recente. - Caso tenha a possibilidade de substituir o Pillow pela versão mais rápida [Pillow-SIMD](https://github.com/uploadcare/pillow-simd), deverá conseguir notar um desempenho consideravelmente superior. É por isso que, por cortesia, @@ -202,6 +197,12 @@ dos ficheiros se optar por reduzir o número de cores utilizando uma paleta adaptativa. Tenha em consideração que ao usar esta opção a qualidade de imagem poderá ser afetada de forma bastante notória. +Desde a versão 1.3.5, a aplicação Optimize Images oferece suporte experimental +para imagens no formato MPO, as quais são tratadas como ficheiros JPEG de imagem +única (caso um ficheiro MPO contenha várias imagens, apenas a primeira será +processada). + + ### ADVERTÊNCIA **Por favor, tenha em consideração que a operação deste programa é feita DE MODO DESTRUTIVO, substituindo os ficheiros originais pelos ficheiros diff --git a/optimize_images/__init__.py b/optimize_images/__init__.py index ac422f1..5b8f37a 100755 --- a/optimize_images/__init__.py +++ b/optimize_images/__init__.py @@ -1 +1 @@ -__version__ = '1.3.4' +__version__ = '1.3.5' diff --git a/optimize_images/__main__.py b/optimize_images/__main__.py index 8a2349c..222d65c 100644 --- a/optimize_images/__main__.py +++ b/optimize_images/__main__.py @@ -26,6 +26,8 @@ """ import os +import piexif + try: from PIL import Image except ImportError: @@ -62,10 +64,28 @@ def do_optimization(t: Task) -> TaskResult: # should skip unsupported formats?) if img.format.upper() == 'PNG': return optimize_png(t) - elif (img.format.upper() == 'JPEG'): + elif img.format.upper() in ('JPEG', 'MPO'): return optimize_jpg(t) else: - pass + try: + had_exif = True if piexif.load(t.src_path)['Exif'] else False + except piexif.InvalidImageDataError: # Not a supported format + had_exif = False + except ValueError: # No exif info + had_exif = False + return TaskResult(img=t.src_path, + orig_format=img.format.upper(), + result_format=img.format.upper(), + orig_mode=img.mode, + result_mode=img.mode, + orig_colors=0, + final_colors=0, + orig_size=os.path.getsize(t.src_path), + final_size=0, + was_optimized=False, + was_downsized=False, + had_exif=had_exif, + has_exif=had_exif) def main(): diff --git a/requirements_development.txt b/requirements_development.txt index 94c380a..61ef1d1 100644 --- a/requirements_development.txt +++ b/requirements_development.txt @@ -1,4 +1,4 @@ -bleach==3.1.0 +bleach==3.1.4 certifi==2019.6.16 cffi==1.12.3 chardet==3.0.4 @@ -7,7 +7,7 @@ docutils==0.14 future==0.17.1 idna==2.8 piexif==1.1.3 -Pillow==6.2.1 +Pillow==6.2.2 pkginfo==1.5.0.1 pycparser==2.19 Pygments==2.4.2 diff --git a/requirements_for_desktop.txt b/requirements_for_desktop.txt index 5605997..fe4de07 100644 --- a/requirements_for_desktop.txt +++ b/requirements_for_desktop.txt @@ -1,2 +1,2 @@ -Pillow>=5.1.0 -piexif>=1.1.2 +Pillow>=6.2.2 +piexif>=1.1.3