From c1e8a8c2e45620e29a4eabbfad93630ec7882829 Mon Sep 17 00:00:00 2001 From: Alex Xu Date: Wed, 24 Mar 2021 20:51:21 -0700 Subject: [PATCH 1/5] Scale and Crop instead of Stretch --- mangle/image.py | 6 ++---- mangle/ui/options.ui | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/mangle/image.py b/mangle/image.py index b9ba9e5..431afab 100644 --- a/mangle/image.py +++ b/mangle/image.py @@ -16,7 +16,7 @@ import os -from PIL import Image, ImageDraw, ImageStat, ImageChops +from PIL import Image, ImageDraw, ImageStat, ImageChops, ImageOps class ImageFlags: @@ -135,9 +135,7 @@ def quantizeImage(image, palette): @protect_bad_image def stretchImage(image, size): - widthDev, heightDev = size - - return image.resize((widthDev, heightDev), Image.ANTIALIAS) + return ImageOps.fit(image, size, Image.ANTIALIAS) @protect_bad_image diff --git a/mangle/ui/options.ui b/mangle/ui/options.ui index dded245..d82b049 100644 --- a/mangle/ui/options.ui +++ b/mangle/ui/options.ui @@ -217,7 +217,7 @@ - Stretch images to fill the screen + Scale and crop images to fill the screen From 38832b8196880910825a2ce0e1a16dfc0139827e Mon Sep 17 00:00:00 2001 From: Alex Xu Date: Thu, 25 Mar 2021 16:36:09 -0700 Subject: [PATCH 2/5] Rename Stretch to ScaleCrop --- mangle/image.py | 6 +++--- mangle/options.py | 6 +++--- mangle/ui/options.ui | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mangle/image.py b/mangle/image.py index 431afab..3257d6e 100644 --- a/mangle/image.py +++ b/mangle/image.py @@ -24,7 +24,7 @@ class ImageFlags: Resize = 1 << 1 Frame = 1 << 2 Quantize = 1 << 3 - Stretch = 1 << 4 + ScaleCrop = 1 << 4 SplitRightLeft = 1 << 5 # split right then left SplitRight = 1 << 6 # split only the right page SplitLeft = 1 << 7 # split only the left page @@ -134,7 +134,7 @@ def quantizeImage(image, palette): @protect_bad_image -def stretchImage(image, size): +def scaleCropImage(image, size): return ImageOps.fit(image, size, Image.ANTIALIAS) @@ -275,7 +275,7 @@ def convertImage(source, target, device, flags): image = orientImage(image, size) if flags & ImageFlags.Resize: image = resizeImage(image, size) - if flags & ImageFlags.Stretch: + if flags & ImageFlags.ScaleCrop: image = stretchImage(image, size) if flags & ImageFlags.Frame: image = frameImage(image, tuple(palette[:3]), tuple(palette[-3:]), size) diff --git a/mangle/options.py b/mangle/options.py index c2437bc..8829463 100644 --- a/mangle/options.py +++ b/mangle/options.py @@ -43,7 +43,7 @@ class DialogOptions(QtGui.QDialog): self.checkboxOverwrite.setChecked(self.book.overwrite) self.checkboxOrient.setChecked(self.book.imageFlags & ImageFlags.Orient) self.checkboxResize.setChecked(self.book.imageFlags & ImageFlags.Resize) - self.checkboxStretch.setChecked(self.book.imageFlags & ImageFlags.Stretch) + self.checkboxScaleCrop.setChecked(self.book.imageFlags & ImageFlags.ScaleCrop) self.checkboxQuantize.setChecked(self.book.imageFlags & ImageFlags.Quantize) self.checkboxFrame.setChecked(self.book.imageFlags & ImageFlags.Frame) @@ -62,8 +62,8 @@ class DialogOptions(QtGui.QDialog): imageFlags |= ImageFlags.Orient if self.checkboxResize.isChecked(): imageFlags |= ImageFlags.Resize - if self.checkboxStretch.isChecked(): - imageFlags |= ImageFlags.Stretch + if self.checkboxScaleCrop.isChecked(): + imageFlags |= ImageFlags.ScaleCrop if self.checkboxQuantize.isChecked(): imageFlags |= ImageFlags.Quantize if self.checkboxFrame.isChecked(): diff --git a/mangle/ui/options.ui b/mangle/ui/options.ui index d82b049..29cedbb 100644 --- a/mangle/ui/options.ui +++ b/mangle/ui/options.ui @@ -215,7 +215,7 @@ - + Scale and crop images to fill the screen From 464826ab1453cf6769b46bddb7ff3c016fd49978 Mon Sep 17 00:00:00 2001 From: Alex Xu Date: Thu, 25 Mar 2021 16:39:09 -0700 Subject: [PATCH 3/5] Forgot one rename --- mangle/image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mangle/image.py b/mangle/image.py index 3257d6e..2fe18b4 100644 --- a/mangle/image.py +++ b/mangle/image.py @@ -276,7 +276,7 @@ def convertImage(source, target, device, flags): if flags & ImageFlags.Resize: image = resizeImage(image, size) if flags & ImageFlags.ScaleCrop: - image = stretchImage(image, size) + image = scaleCropImage(image, size) if flags & ImageFlags.Frame: image = frameImage(image, tuple(palette[:3]), tuple(palette[-3:]), size) if flags & ImageFlags.Quantize: From d7866df9c4e41b612016731b74507aadd83b197c Mon Sep 17 00:00:00 2001 From: Alex Xu Date: Thu, 25 Mar 2021 16:50:51 -0700 Subject: [PATCH 4/5] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1f774fc..5c53af2 100644 --- a/setup.py +++ b/setup.py @@ -44,7 +44,7 @@ setup( 'bundle_files': 1, 'includes': ['sip'], 'packages': ['reportlab.pdfbase'], - 'dll_excludes': ['w9xpopen.exe'] + 'dll_excludes': ['MSVCP90.dll', 'w9xpopen.exe'] }}, zipfile=None ) From 7a1d42cd43932d2592c8af9d422d992b8cfe1794 Mon Sep 17 00:00:00 2001 From: Alex Xu Date: Thu, 25 Mar 2021 17:01:20 -0700 Subject: [PATCH 5/5] Revert "Update setup.py" This reverts commit d7866df9c4e41b612016731b74507aadd83b197c. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5c53af2..1f774fc 100644 --- a/setup.py +++ b/setup.py @@ -44,7 +44,7 @@ setup( 'bundle_files': 1, 'includes': ['sip'], 'packages': ['reportlab.pdfbase'], - 'dll_excludes': ['MSVCP90.dll', 'w9xpopen.exe'] + 'dll_excludes': ['w9xpopen.exe'] }}, zipfile=None )