コード例 #1
0
 def test_manipulate(self):
     """Manipulation of files."""
     # Currently only runs through
     # TODO find a way to check if the image was manipulated correctly
     imageactions.manipulate_all(self.filename, self.filename,
                                 [10, 10, 10, False])
     imageactions.manipulate_all(self.filename, self.filename,
                                 [0, 0, 0, True])
コード例 #2
0
ファイル: manipulate.py プロジェクト: karlch/vimiv
    def manipulate_image(self, real=""):
        """Apply manipulations to image.

        Manipulations are the three sliders for brightness, contrast and
        sharpness and optimize from ImageMagick. They are applied to a thumbnail
        by default and can act on the real image.

        Args:
            real: If set, apply manipulations to the real image.
        """
        if real:  # To the actual image?
            orig, out = real, real
        # A thumbnail for higher responsiveness
        elif "-EDIT" not in self.app.paths[self.app.index]:
            with open(self.app.paths[self.app.index], "rb") as image_file:
                im = Image.open(image_file)
                out = "-EDIT.".join(
                    self.app.paths[self.app.index].rsplit(".", 1))
                orig = out.replace("EDIT", "EDIT-ORIG")
                im.thumbnail(self.app["image"].imsize, Image.ANTIALIAS)
                imageactions.save_image(im, out)
                self.app.paths[self.app.index] = out
                # Save the original to work with
                imageactions.save_image(im, orig)
        else:
            out = self.app.paths[self.app.index]
            orig = out.replace("EDIT", "EDIT-ORIG")
        # Apply all manipulations
        if imageactions.manipulate_all(orig, out, self.manipulations):
            self.app["statusbar"].err_message(
                "Optimize failed. Is imagemagick installed?")

        # Show the edited image
        self.app["image"].image.clear()
        self.app["image"].pixbuf_original = \
            GdkPixbuf.PixbufAnimation.new_from_file(
                out)
        self.app["image"].pixbuf_original = \
            self.app["image"].pixbuf_original.get_static_image()
        if not self.app["window"].is_fullscreen:
            self.app["image"].imsize = self.app["image"].get_available_size()
        self.app["image"].zoom_percent = \
            self.app["image"].get_zoom_percent_to_fit()
        self.app["image"].update()
コード例 #3
0
    def manipulate_image(self, real=""):
        """Apply manipulations to image.

        Manipulations are the three sliders for brightness, contrast and
        sharpness and optimize from ImageMagick. They are applied to a thumbnail
        by default and can act on the real image.

        Args:
            real: If set, apply manipulations to the real image.
        """
        if real:  # To the actual image?
            orig, out = real, real
        # A thumbnail for higher responsiveness
        elif "-EDIT" not in self.vimiv.paths[self.vimiv.index]:
            with open(self.vimiv.paths[self.vimiv.index], "rb") as image_file:
                im = Image.open(image_file)
                out = "-EDIT.".join(self.vimiv.paths[self.vimiv.index].rsplit(
                    ".", 1))
                orig = out.replace("EDIT", "EDIT-ORIG")
                im.thumbnail(self.vimiv.image.imsize, Image.ANTIALIAS)
                imageactions.save_image(im, out)
                self.vimiv.paths[self.vimiv.index] = out
                # Save the original to work with
                imageactions.save_image(im, orig)
        else:
            out = self.vimiv.paths[self.vimiv.index]
            orig = out.replace("EDIT", "EDIT-ORIG")
        # Apply all manipulations
        if imageactions.manipulate_all(orig, out, self.manipulations):
            self.vimiv.statusbar.err_message(
                "Optimize failed. Is imagemagick installed?")

        # Show the edited image
        self.vimiv.image.image.clear()
        self.vimiv.image.pixbuf_original = \
            GdkPixbuf.PixbufAnimation.new_from_file(
                out)
        self.vimiv.image.pixbuf_original = \
            self.vimiv.image.pixbuf_original.get_static_image()
        if not self.vimiv.window.fullscreen:
            self.vimiv.image.imsize = self.vimiv.image.get_available_size()
        self.vimiv.image.zoom_percent = self.vimiv.image.get_zoom_percent()
        self.vimiv.image.update()
コード例 #4
0
ファイル: imageactions_test.py プロジェクト: karlch/vimiv
 def test_manipulate(self):
     """Manipulation of files."""
     # Currently only runs through
     # TODO find a way to check if the image was manipulated correctly
     imageactions.manipulate_all(self.filename, self.filename, [10, 10, 10, False])
     imageactions.manipulate_all(self.filename, self.filename, [0, 0, 0, True])