diff --git a/changes/265.bugfix b/changes/265.bugfix new file mode 100644 index 0000000..7416ef5 --- /dev/null +++ b/changes/265.bugfix @@ -0,0 +1 @@ +Fix sending image resize dialog. diff --git a/d_rats/image.py b/d_rats/image.py index 82a7f0a..484212c 100755 --- a/d_rats/image.py +++ b/d_rats/image.py @@ -5,6 +5,17 @@ import logging import tempfile import os +if __name__ == "__main__": + import sys + +HAVE_PIL = False +try: + from PIL import Image + from PIL import UnidentifiedImageError + HAVE_PIL = True +except ImportError: + # This needs to be moved out of main_common + from .ui.main_common import ask_for_confirmation import gi gi.require_version("Gtk", "3.0") @@ -118,8 +129,11 @@ def update(): dialog.size = miscwidgets.make_choice(SIZES, False, SIZES[1]) dialog.size.connect("changed", lambda x: update()) dialog.add_field(_("Resize to"), dialog.size) - - quality = Gtk.HScale(Gtk.Adjustment.new(50, 1, 100, 10, 10, 0)) + adjustment = Gtk.Adjustment.new(value=50, lower=1, upper=100, + step_increment=10, page_increment=10, + page_size=0) + quality = Gtk.Scale.new(orientation=Gtk.Orientation.HORIZONTAL, + adjustment=adjustment) quality.connect("format-value", lambda s, v: "%i" % v) quality.connect("change-value", set_quality, dialog) @@ -153,12 +167,11 @@ def send_image(filename, dialog_parent=None): :returns: Path to temporary image file :rtype: str ''' - try: - from PIL import Image, UnidentifiedImageError - except ImportError: + logger = logging.getLogger("update_image") + if not HAVE_PIL: + logger.info("Python pillow library is not installed.") msg = _("No support for resizing images. Send unaltered?") - from .ui import main_common - if main_common.ask_for_confirmation(msg, dialog_parent): + if ask_for_confirmation(msg, dialog_parent): return filename return None try: @@ -185,8 +198,6 @@ def send_image(filename, dialog_parent=None): def main(): '''Main for Unit testing.''' - import sys - logging.basicConfig(format="%(asctime)s:%(levelname)s:%(name)s:%(message)s", datefmt="%m/%d/%Y %H:%M:%S", level=logging.INFO)