Răsfoiți Sursa

Bug Fixes:
Fixed blur scaling issue,
Fixed error after exporting JPG image,
Disabled Undo/Redo buttons while processing,
Changed namespace from com.pcthingz.photofidd2 to com.pcthingz.photofiddle.

Signed-off-by: Billy Barrow <billyb@pcthingz.com>

Billy Barrow 8 ani în urmă
părinte
comite
845f6b6b1f
5 a modificat fișierele cu 58 adăugiri și 29 ștergeri
  1. 5 1
      PF2/Tools/Blur.py
  2. 5 1
      PF2/Tools/Details.py
  3. 8 4
      PF2/Tools/Tonemap.py
  4. 39 22
      PF2/__init__.py
  5. 1 1
      PhotoFiddle.py

+ 5 - 1
PF2/Tools/Blur.py

@@ -28,8 +28,12 @@ class Blur(Tool.Tool):
             strength = self.props["strength"].get_value()
             method = self.props["method"].get_value()
 
+            height, width = image.shape[:2]
+            size = (height*width)
+            mul = numpy.math.sqrt(size) / 1064.416 #numpy.math.sqrt(1132982.0)
+
             if (strength > 0):
-                blur_size = 2 * round((round(strength) + 1) / 2) - 1
+                blur_size = 2 * round((round(strength*mul) + 1) / 2) - 1
                 if(method == 0):
                     im = cv2.GaussianBlur(im, (int(blur_size), int(blur_size)), 0)
 

+ 5 - 1
PF2/Tools/Details.py

@@ -56,7 +56,11 @@ class Details(Tool.Tool):
 
             # Blur
             if(detail > 0):
-                blur_size = 2 * round((round(detail) + 1) / 2) - 1
+                height, width = image.shape[:2]
+                size = (height * width)
+                mul = numpy.math.sqrt(size) / 1064.416
+
+                blur_size = 2 * round((round(detail*mul) + 1) / 2) - 1
                 blurred = cv2.GaussianBlur(edged, (int(blur_size), int(blur_size)), 0)
             else:
                 blurred = edged

+ 8 - 4
PF2/Tools/Tonemap.py

@@ -1,4 +1,5 @@
 import cv2
+import numpy
 
 import Tool
 
@@ -11,7 +12,7 @@ class Tonemap(Tool.Tool):
         self.properties = [
             Tool.Property("enabled", "Tone Mapping", "Header", False, has_toggle=True, has_button=False),
             Tool.Property("strength", "Strength", "Slider", 90, max=100, min=0),
-            Tool.Property("bleed", "Bleed", "Slider", 10, max=100, min=0),
+            Tool.Property("bleed", "Sharpness", "Slider", 10, max=100, min=0),
             Tool.Property("contrast", "Contrast", "Slider", 25, max=100, min=0),
             Tool.Property("two_pass", "Two Pass", "Toggle", False)
         ]
@@ -38,9 +39,12 @@ class Tonemap(Tool.Tool):
 
                 # Blur
                 if(blur > 0):
-                    height, width = inverted.shape[:2]
-                    imsize = (height + width) / float(2)
-                    blur_size = 2 * round(round((imsize * (blur / 100.0)) / 2)) - 1
+
+                    height, width = image.shape[:2]
+                    size = (height * width)
+                    mul = numpy.math.sqrt(size) / 1064.416  # numpy.math.sqrt(1132982.0)
+
+                    blur_size = 2 * round((round((blur/10.0) * mul) + 1) / 2) - 1
                     blurred = cv2.GaussianBlur(inverted, (int(blur_size), int(blur_size)), 0)
                 else:
                     # Or, don't blur

+ 39 - 22
PF2/__init__.py

@@ -378,8 +378,8 @@ class PF2(Activity.Activity):
         self.on_export_state_change()
 
     def update_undo_state(self):
-        self.ui["undo"].set_sensitive(self.undo_position > 0)
-        self.ui["redo"].set_sensitive(len(self.undo_stack)-1 > self.undo_position)
+        self.ui["undo"].set_sensitive((self.undo_position > 0) and (not self.is_working))
+        self.ui["redo"].set_sensitive((len(self.undo_stack)-1 > self.undo_position)  and (not self.is_working))
 
     def on_undo(self, sender):
         self.pre_undo_layer_name = self.get_selected_layer().name
@@ -497,10 +497,18 @@ class PF2(Activity.Activity):
         if(not immediate):
             time.sleep(0.5)
         self.additional_change_occurred = False
+        self.is_working = True
+        GLib.idle_add(self.update_undo_state)
         GLib.idle_add(self.start_work)
         image = numpy.copy(self.original_image)
         rst = time.time()
         self.image = self.run_stack(image, changed_layer=changed_layer)
+        if(self.image == None):
+            GLib.idle_add(self.stop_work)
+            self.is_working = False
+            GLib.idle_add(self.update_undo_state)
+            raise Exception()
+
         self.process_mask()
         self.image_is_dirty = False
         if(self.additional_change_occurred):
@@ -511,6 +519,8 @@ class PF2(Activity.Activity):
             self.process_peaks()
             self.update_preview()
             GLib.idle_add(self.stop_work)
+            self.is_working = False
+            GLib.idle_add(self.update_undo_state)
             self.change_occurred = False
             self.undoing = False
 
@@ -522,38 +532,45 @@ class PF2(Activity.Activity):
 
             baseImage = image.copy()
 
-            image = None
+            try:
 
-            carry = True
-            if(baseImage.shape == self.image.shape) and (changed_layer != None) and (changed_layer in self.layers):
-                changed_layer_index = self.layers.index(changed_layer)
-                if(changed_layer_index > 0):
-                    carry = False
-                    layer_under = self.layers[changed_layer_index -1]
-                    image = layer_under.layer_copy.copy()
-                    for layer in self.layers[changed_layer_index: ]:
+                image = None
+
+                carry = True
+                if(self.image != None) and (baseImage.shape == self.image.shape) and (changed_layer != None) and (changed_layer in self.layers):
+                    changed_layer_index = self.layers.index(changed_layer)
+                    if(changed_layer_index > 0):
+                        carry = False
+                        layer_under = self.layers[changed_layer_index -1]
+                        image = layer_under.layer_copy.copy()
+                        for layer in self.layers[changed_layer_index: ]:
+                            self.current_processing_layer_name = layer.name
+                            self.current_processing_layer_index = self.layers.index(layer)
+                            if(self.additional_change_occurred):
+                                break
+                            print(layer)
+                            image = layer.render_layer(baseImage, image, callback)
+
+
+                if(carry):
+                    for layer in self.layers:
                         self.current_processing_layer_name = layer.name
                         self.current_processing_layer_index = self.layers.index(layer)
-                        if(self.additional_change_occurred):
+                        if (self.additional_change_occurred):
                             break
                         print(layer)
                         image = layer.render_layer(baseImage, image, callback)
 
 
-            if(carry):
-                for layer in self.layers:
-                    self.current_processing_layer_name = layer.name
-                    self.current_processing_layer_index = self.layers.index(layer)
-                    if (self.additional_change_occurred):
-                        break
-                    print(layer)
-                    image = layer.render_layer(baseImage, image, callback)
 
 
+                self.running_stack = False
+                return image
 
+            except(Exception):
+                GLib.idle_add(self.show_message, "Image Render Failed…",
+                              "PhotoFiddle encountered an internal error and was unable to render the image.")
 
-            self.running_stack = False
-            return image
 
         else:
             while(self.running_stack):

+ 1 - 1
PhotoFiddle.py

@@ -22,7 +22,7 @@ Gtk.Settings.get_default().set_property("gtk_application_prefer_dark_theme", Tru
 class App(Gtk.Application):
     def __init__(self):
         Gtk.Application.__init__(self,
-                                 application_id="com.pcthingz.photofiddle2",
+                                 application_id="com.pcthingz.photofiddle",
                                  flags=Gio.ApplicationFlags.FLAGS_NONE)
 
         self.connect("activate", self.activateCb)