Advertisement
Guest User

Untitled

a guest
Apr 24th, 2020
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 6.59 KB | None | 0 0
  1. From 944d44359dd347f05f952e1ad0be0991a6753ad8 Mon Sep 17 00:00:00 2001
  2. From: Gr3q <floyd0122@gmail.com>
  3. Date: Fri, 24 Apr 2020 19:16:58 +0100
  4. Subject: [PATCH] Revert "Add optimizations to image downscaling, update Pillow
  5.  requirement"
  6.  
  7. This reverts commit 6eecf85a628cc898b943959920e7fb479b985044.
  8. ---
  9. requirements_cli.txt                |  2 +-
  10.  requirements_full_linux.txt         |  2 +-
  11.  requirements_full_windows.txt       |  2 +-
  12.  setup.py                            |  2 +-
  13.  superpaper/configuration_dialogs.py |  9 ++-------
  14.  superpaper/gui.py                   | 16 +++++-----------
  15.  superpaper/wallpaper_processing.py  | 13 +++----------
  16.  7 files changed, 14 insertions(+), 32 deletions(-)
  17.  
  18. diff --git a/requirements_cli.txt b/requirements_cli.txt
  19. index 4144e3f..352ddb7 100644
  20. --- a/requirements_cli.txt
  21. +++ b/requirements_cli.txt
  22. @@ -1,3 +1,3 @@
  23. -Pillow>=7.0.0
  24. +Pillow>=6.0.0
  25.  screeninfo>=0.6.1
  26.  numpy>=1.18.0
  27. diff --git a/requirements_full_linux.txt b/requirements_full_linux.txt
  28. index 53ad2a4..4e02e73 100644
  29. --- a/requirements_full_linux.txt
  30. +++ b/requirements_full_linux.txt
  31. @@ -1,4 +1,4 @@
  32. -Pillow>=7.0.0
  33. +Pillow>=6.0.0
  34.  screeninfo>=0.6.1
  35.  numpy>=1.18.0
  36.  system_hotkey>=1.0
  37. diff --git a/requirements_full_windows.txt b/requirements_full_windows.txt
  38. index 975f375..eb74343 100644
  39. --- a/requirements_full_windows.txt
  40. +++ b/requirements_full_windows.txt
  41. @@ -1,4 +1,4 @@
  42. -Pillow>=7.0.0
  43. +Pillow>=6.0.0
  44.  screeninfo>=0.6.1
  45.  numpy>=1.18.0
  46.  wxPython>=4.0.4
  47. diff --git a/setup.py b/setup.py
  48. index 5362176..f7ff6ab 100644
  49. --- a/setup.py
  50. +++ b/setup.py
  51. @@ -58,7 +58,7 @@ if __name__ == "__main__":
  52.  
  53.          # python_requires="~=3.5",
  54.          install_requires=[
  55. -            "Pillow>=7.0.0",
  56. +            "Pillow>=6.0.0",
  57.              "screeninfo>=0.6.1",
  58.              "numpy>=1.18.0",
  59.              "system_hotkey>=1.0.3",
  60. diff --git a/superpaper/configuration_dialogs.py b/superpaper/configuration_dialogs.py
  61. index a857a50..2d4f017 100644
  62. --- a/superpaper/configuration_dialogs.py
  63. +++ b/superpaper/configuration_dialogs.py
  64. @@ -170,12 +170,7 @@ class BrowsePaths(wx.Dialog):
  65.              target_h = self.tsize[1]
  66.              target_w = target_h*w2h_ratio
  67.              pos = (round((target_h - target_w)/2), 0)
  68. -        bmp = wximg.Scale(target_w,
  69. -                          target_h,
  70. -                          quality=wx.IMAGE_QUALITY_BOX_AVERAGE
  71. -                         ).Resize(self.tsize,
  72. -                                  pos
  73. -                                 ).ConvertToBitmap()
  74. +        bmp = wximg.Scale(target_w, target_h).Resize(self.tsize, pos).ConvertToBitmap()
  75.          return bmp
  76.  
  77.      #
  78. @@ -186,7 +181,7 @@ class BrowsePaths(wx.Dialog):
  79.          """Adds selected path to export field."""
  80.          path_data_tuples = []
  81.          sel_path = self.dir3.GetPath()
  82. -        # self.dir3.GetPaths(paths) # more efficient but couldn't get to work
  83. +        # self.dir3.GetPaths(paths) # could use this to be more efficient but it does not will the list
  84.          if self.use_multi_image:
  85.              # Extra column in advanced mode
  86.              disp_id = str(self.radiobox_displays.GetSelection())
  87. diff --git a/superpaper/gui.py b/superpaper/gui.py
  88. index 37367d3..89b54e5 100644
  89. --- a/superpaper/gui.py
  90. +++ b/superpaper/gui.py
  91. @@ -77,9 +77,9 @@ class WallpaperSettingsPanel(wx.Panel):
  92.          # self.sizer_top_half.SetMinSize()
  93.          self.wpprev_pnl.Bind(wx.EVT_SIZE, self.onResize)
  94.          self.wpprev_pnl.Bind(wx.EVT_IDLE, self.onIdle)
  95. -
  96. +        
  97.          # bottom half
  98. -
  99. +        
  100.          # profile sizer contents
  101.          self.create_sizer_profiles()
  102.  
  103. @@ -816,13 +816,7 @@ class WallpaperSettingsPanel(wx.Panel):
  104.              target_h = self.tsize[1]
  105.              target_w = target_h*w2h_ratio
  106.              pos = (round((target_h - target_w)/2), 0)
  107. -        bmp = wximg.Scale(
  108. -            target_w,
  109. -            target_h,
  110. -            quality=wx.IMAGE_QUALITY_BOX_AVERAGE
  111. -            ).Resize(
  112. -                self.tsize, pos
  113. -            ).ConvertToBitmap()
  114. +        bmp = wximg.Scale(target_w, target_h).Resize(self.tsize, pos).ConvertToBitmap()
  115.          return bmp
  116.  
  117.      def populate_lc_browse(self, pathslist, imglist):
  118. @@ -1465,9 +1459,9 @@ class WallpaperPreviewPanel(wx.Panel):
  119.          self.draw_monitor_numbers(use_ppi_px)
  120.          self.Refresh()
  121.  
  122. -    def resize_and_bitmap(self, fname, size, enhance_color=False):
  123. +    def resize_and_bitmap(self, fname, size, enhance_color = False):
  124.          """Take filename of an image and resize and center crop it to size."""
  125. -        pil = resize_to_fill(Image.open(fname), size, quality="fast")
  126. +        pil = resize_to_fill(Image.open(fname), size)
  127.          img = wx.Image(pil.size[0], pil.size[1])
  128.          img.SetData(pil.convert("RGB").tobytes())
  129.          if enhance_color:
  130. diff --git a/superpaper/wallpaper_processing.py b/superpaper/wallpaper_processing.py
  131. index c34e93a..24776cc 100644
  132. --- a/superpaper/wallpaper_processing.py
  133. +++ b/superpaper/wallpaper_processing.py
  134. @@ -847,15 +847,8 @@ def compute_ppi_corrected_res_array(res_array, ppi_list_rel_density):
  135.  
  136.  # resize image to fill given rectangle and do a centered crop to size.
  137.  # Return output image.
  138. -def resize_to_fill(img, res, quality=Image.LANCZOS):
  139. +def resize_to_fill(img, res):
  140.      """Resize image to fill given rectangle and do a centered crop to size."""
  141. -    if quality == "fast":
  142. -        quality = Image.HAMMING
  143. -        reducing_gap = 1.5
  144. -    else:
  145. -        quality = Image.LANCZOS
  146. -        reducing_gap = None
  147. -
  148.      image_size = img.size  # returns image (width,height)
  149.      if image_size == res:
  150.          # input image is already of the correct size, no action needed.
  151. @@ -869,7 +862,7 @@ def resize_to_fill(img, res, quality=Image.LANCZOS):
  152.          new_size = (
  153.              round(resize_multiplier * image_size[0]),
  154.              round(resize_multiplier * image_size[1]))
  155. -        img = img.resize(new_size, resample=quality, reducing_gap=reducing_gap)
  156. +        img = img.resize(new_size, resample=Image.LANCZOS)
  157.          # crop vertically to target height
  158.          extra_height = new_size[1] - res[1]
  159.          if extra_height < 0:
  160. @@ -900,7 +893,7 @@ def resize_to_fill(img, res, quality=Image.LANCZOS):
  161.          new_size = (
  162.              round(resize_multiplier * image_size[0]),
  163.              round(resize_multiplier * image_size[1]))
  164. -        img = img.resize(new_size, resample=quality, reducing_gap=reducing_gap)
  165. +        img = img.resize(new_size, resample=Image.LANCZOS)
  166.          # crop horizontally to target width
  167.          extra_width = new_size[0] - res[0]
  168.          if extra_width < 0:
  169. --
  170. 2.26.2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement