From 944d44359dd347f05f952e1ad0be0991a6753ad8 Mon Sep 17 00:00:00 2001 From: Gr3q Date: Fri, 24 Apr 2020 19:16:58 +0100 Subject: [PATCH] Revert "Add optimizations to image downscaling, update Pillow requirement" This reverts commit 6eecf85a628cc898b943959920e7fb479b985044. --- requirements_cli.txt | 2 +- requirements_full_linux.txt | 2 +- requirements_full_windows.txt | 2 +- setup.py | 2 +- superpaper/configuration_dialogs.py | 9 ++------- superpaper/gui.py | 16 +++++----------- superpaper/wallpaper_processing.py | 13 +++---------- 7 files changed, 14 insertions(+), 32 deletions(-) diff --git a/requirements_cli.txt b/requirements_cli.txt index 4144e3f..352ddb7 100644 --- a/requirements_cli.txt +++ b/requirements_cli.txt @@ -1,3 +1,3 @@ -Pillow>=7.0.0 +Pillow>=6.0.0 screeninfo>=0.6.1 numpy>=1.18.0 diff --git a/requirements_full_linux.txt b/requirements_full_linux.txt index 53ad2a4..4e02e73 100644 --- a/requirements_full_linux.txt +++ b/requirements_full_linux.txt @@ -1,4 +1,4 @@ -Pillow>=7.0.0 +Pillow>=6.0.0 screeninfo>=0.6.1 numpy>=1.18.0 system_hotkey>=1.0 diff --git a/requirements_full_windows.txt b/requirements_full_windows.txt index 975f375..eb74343 100644 --- a/requirements_full_windows.txt +++ b/requirements_full_windows.txt @@ -1,4 +1,4 @@ -Pillow>=7.0.0 +Pillow>=6.0.0 screeninfo>=0.6.1 numpy>=1.18.0 wxPython>=4.0.4 diff --git a/setup.py b/setup.py index 5362176..f7ff6ab 100644 --- a/setup.py +++ b/setup.py @@ -58,7 +58,7 @@ if __name__ == "__main__": # python_requires="~=3.5", install_requires=[ - "Pillow>=7.0.0", + "Pillow>=6.0.0", "screeninfo>=0.6.1", "numpy>=1.18.0", "system_hotkey>=1.0.3", diff --git a/superpaper/configuration_dialogs.py b/superpaper/configuration_dialogs.py index a857a50..2d4f017 100644 --- a/superpaper/configuration_dialogs.py +++ b/superpaper/configuration_dialogs.py @@ -170,12 +170,7 @@ class BrowsePaths(wx.Dialog): target_h = self.tsize[1] target_w = target_h*w2h_ratio pos = (round((target_h - target_w)/2), 0) - bmp = wximg.Scale(target_w, - target_h, - quality=wx.IMAGE_QUALITY_BOX_AVERAGE - ).Resize(self.tsize, - pos - ).ConvertToBitmap() + bmp = wximg.Scale(target_w, target_h).Resize(self.tsize, pos).ConvertToBitmap() return bmp # @@ -186,7 +181,7 @@ class BrowsePaths(wx.Dialog): """Adds selected path to export field.""" path_data_tuples = [] sel_path = self.dir3.GetPath() - # self.dir3.GetPaths(paths) # more efficient but couldn't get to work + # self.dir3.GetPaths(paths) # could use this to be more efficient but it does not will the list if self.use_multi_image: # Extra column in advanced mode disp_id = str(self.radiobox_displays.GetSelection()) diff --git a/superpaper/gui.py b/superpaper/gui.py index 37367d3..89b54e5 100644 --- a/superpaper/gui.py +++ b/superpaper/gui.py @@ -77,9 +77,9 @@ class WallpaperSettingsPanel(wx.Panel): # self.sizer_top_half.SetMinSize() self.wpprev_pnl.Bind(wx.EVT_SIZE, self.onResize) self.wpprev_pnl.Bind(wx.EVT_IDLE, self.onIdle) - + # bottom half - + # profile sizer contents self.create_sizer_profiles() @@ -816,13 +816,7 @@ class WallpaperSettingsPanel(wx.Panel): target_h = self.tsize[1] target_w = target_h*w2h_ratio pos = (round((target_h - target_w)/2), 0) - bmp = wximg.Scale( - target_w, - target_h, - quality=wx.IMAGE_QUALITY_BOX_AVERAGE - ).Resize( - self.tsize, pos - ).ConvertToBitmap() + bmp = wximg.Scale(target_w, target_h).Resize(self.tsize, pos).ConvertToBitmap() return bmp def populate_lc_browse(self, pathslist, imglist): @@ -1465,9 +1459,9 @@ class WallpaperPreviewPanel(wx.Panel): self.draw_monitor_numbers(use_ppi_px) self.Refresh() - def resize_and_bitmap(self, fname, size, enhance_color=False): + def resize_and_bitmap(self, fname, size, enhance_color = False): """Take filename of an image and resize and center crop it to size.""" - pil = resize_to_fill(Image.open(fname), size, quality="fast") + pil = resize_to_fill(Image.open(fname), size) img = wx.Image(pil.size[0], pil.size[1]) img.SetData(pil.convert("RGB").tobytes()) if enhance_color: diff --git a/superpaper/wallpaper_processing.py b/superpaper/wallpaper_processing.py index c34e93a..24776cc 100644 --- a/superpaper/wallpaper_processing.py +++ b/superpaper/wallpaper_processing.py @@ -847,15 +847,8 @@ def compute_ppi_corrected_res_array(res_array, ppi_list_rel_density): # resize image to fill given rectangle and do a centered crop to size. # Return output image. -def resize_to_fill(img, res, quality=Image.LANCZOS): +def resize_to_fill(img, res): """Resize image to fill given rectangle and do a centered crop to size.""" - if quality == "fast": - quality = Image.HAMMING - reducing_gap = 1.5 - else: - quality = Image.LANCZOS - reducing_gap = None - image_size = img.size # returns image (width,height) if image_size == res: # input image is already of the correct size, no action needed. @@ -869,7 +862,7 @@ def resize_to_fill(img, res, quality=Image.LANCZOS): new_size = ( round(resize_multiplier * image_size[0]), round(resize_multiplier * image_size[1])) - img = img.resize(new_size, resample=quality, reducing_gap=reducing_gap) + img = img.resize(new_size, resample=Image.LANCZOS) # crop vertically to target height extra_height = new_size[1] - res[1] if extra_height < 0: @@ -900,7 +893,7 @@ def resize_to_fill(img, res, quality=Image.LANCZOS): new_size = ( round(resize_multiplier * image_size[0]), round(resize_multiplier * image_size[1])) - img = img.resize(new_size, resample=quality, reducing_gap=reducing_gap) + img = img.resize(new_size, resample=Image.LANCZOS) # crop horizontally to target width extra_width = new_size[0] - res[0] if extra_width < 0: -- 2.26.2