Esempio n. 1
0
    def on_enter(self):
        """Called when screen is entered, set up the needed variables and image viewer."""

        app = App.get_running_app()

        #set up sort buttons
        self.left_sort_dropdown = DatabaseSortDropDown()
        self.left_sort_dropdown.bind(
            on_select=lambda instance, x: self.resort_method_left(x))
        self.left_sort_method = app.config.get('Sorting', 'database_sort')
        self.left_sort_reverse = to_bool(
            app.config.get('Sorting', 'database_sort_reverse'))
        self.right_sort_dropdown = DatabaseSortDropDown()
        self.right_sort_dropdown.bind(
            on_select=lambda instance, x: self.resort_method_right(x))
        self.right_sort_method = app.config.get('Sorting', 'database_sort')
        self.right_sort_reverse = to_bool(
            app.config.get('Sorting', 'database_sort_reverse'))

        databases = app.get_database_directories()
        self.database_dropdown_left = NormalDropDown()
        self.database_dropdown_right = NormalDropDown()
        for database in databases:
            database_button_left = MenuButton(text=database)
            database_button_left.bind(on_release=self.set_database_left)
            self.database_dropdown_left.add_widget(database_button_left)
            database_button_right = MenuButton(text=database)
            database_button_right.bind(on_release=self.set_database_right)
            self.database_dropdown_right.add_widget(database_button_right)
        self.left_database = databases[0]
        self.right_database = databases[1]
        self.update_treeview()
    def on_enter(self):
        """Called when the screen is entered.  Set up variables and widgets, and prepare to view images."""

        app = App.get_running_app()
        self.set_collage()
        self.ids['leftpanel'].width = app.left_panel_width()
        self.ids['moveButton'].state = 'down'
        self.ids['rotateButton'].state = 'normal'
        self.color_select = ColorDropDown(owner=self)
        self.resolution_select = ResolutionDropDown(owner=self)
        self.aspect_select = ExportAspectRatioDropDown(owner=self)
        self.add_remove = AddRemoveDropDown(owner=self)
        self.collage_type_select = CollageTypeDropDown(owner=self)

        #import variables
        self.target = app.export_target
        self.type = app.export_type

        #set up sort buttons
        self.sort_dropdown = AlbumSortDropDown()
        self.sort_dropdown.bind(on_select=lambda instance, x: self.resort_method(x))
        self.sort_method = app.config.get('Sorting', 'album_sort')
        self.sort_reverse = to_bool(app.config.get('Sorting', 'album_sort_reverse'))

        #refresh views
        self.refresh_photolist()
        self.refresh_photoview()
Esempio n. 3
0
    def on_enter(self):
        """Called when this screen is entered.  Sets up widgets and gets the photo list."""

        self.selected_preset = -1
        app = App.get_running_app()
        self.exporting = False
        self.sort_dropdown = AlbumSortDropDown()
        self.sort_dropdown.bind(
            on_select=lambda instance, x: self.resort_method(x))
        self.sort_method = app.config.get('Sorting', 'album_sort')
        self.sort_reverse = to_bool(
            app.config.get('Sorting', 'album_sort_reverse'))
        self.target = app.export_target
        self.type = app.export_type

        #Get photos
        self.photos = []
        if self.type == 'Album':
            for albuminfo in app.albums:
                if albuminfo['name'] == self.target:
                    photo_paths = albuminfo['photos']
                    for fullpath in photo_paths:
                        photoinfo = app.Photo.exist(fullpath)
                        if photoinfo:
                            self.photos.append(photoinfo)
        elif self.type == 'Tag':
            self.photos = app.Tag.photos(self.target)
        else:
            self.photos = app.Photo.by_folder(self.target)

        self.update_treeview()
        self.update_photolist()
        photos = self.ids['photos']
        photos.select_all()
        self.update_selected()
Esempio n. 4
0
 def __init__(self, **kwargs):
     self.setup_dropdowns()
     app = App.get_running_app()
     encoding_preset = app.config.get('Presets', 'encoding')
     if encoding_preset:
         encoding_settings = encoding_preset.split(',', 10)
         if len(encoding_settings) == 11:
             self.file_format = encoding_settings[0]
             self.video_codec = encoding_settings[1]
             self.audio_codec = encoding_settings[2]
             self.resize = to_bool(encoding_settings[3])
             self.resize_width = encoding_settings[4]
             self.resize_height = encoding_settings[5]
             self.video_bitrate = encoding_settings[6]
             self.audio_bitrate = encoding_settings[7]
             self.encoding_speed = encoding_settings[8]
             self.deinterlace = to_bool(encoding_settings[9])
             self.command_line = encoding_settings[10]
     super(EditConvertVideo, self).__init__(**kwargs)
Esempio n. 5
0
    def _load_fullsize(self):
        app = App.get_running_app()
        if not self.lowmem:
            low_memory = to_bool(app.config.get("Settings", "lowmem"))
        else:
            low_memory = True
        if not low_memory:
            #load a screen-sized image instead of full-sized to save memory
            if os.path.splitext(self.source)[1].lower() == '.bmp':
                #default image loader messes up bmp files, use pil instead
                self._coreimage = ImageLoaderPIL(self.source)
            else:
                self._coreimage = KivyImage(source=self.source)
        else:
            #load and rescale image
            original_image = Image.open(self.source)
            image = original_image.copy()
            original_image.close()
            resize_width = Window.size[0]
            if image.size[0] > resize_width:
                width = int(resize_width)
                height = int(resize_width * (image.size[1] / image.size[0]))
                if width < 10:
                    width = 10
                if height < 10:
                    height = 10
                image = image.resize((width, height))
            if image.mode != 'RGB':
                image = image.convert('RGB')
            image_bytes = BytesIO()
            image.save(image_bytes, 'jpeg')
            image_bytes.seek(0)
            self._coreimage = CoreImage(image_bytes, ext='jpg')

        self.texture = self._coreimage.texture
        if self.mirror:
            self.texture.flip_horizontal()
Esempio n. 6
0
    def update_preview(self, *_):
        #Gets the denoised preview image and updates it in the ui

        #convert pil image to bytes and display background image
        app = App.get_running_app()
        if to_bool(app.config.get("Settings", "lowmem")):
            image = self.owner.viewer.edit_image.edit_image
        else:
            image = self.owner.viewer.edit_image.original_image
        noise_preview = self.ids['noisePreview']
        if image.mode != 'RGB':
            image = image.convert('RGB')
        image_bytes = BytesIO()
        image.save(image_bytes, 'jpeg')
        image_bytes.seek(0)
        noise_preview._coreimage = CoreImage(image_bytes, ext='jpg')
        noise_preview._on_tex_change()

        #update overlay image
        scroll_area = self.ids['wrapper']
        width = scroll_area.size[0]
        height = scroll_area.size[1]
        pos_x = int((self.image_x * scroll_area.scroll_x) -
                    (width * scroll_area.scroll_x))
        image_pos_y = self.image_y - int(
            (self.image_y * scroll_area.scroll_y) +
            (width * (1 - scroll_area.scroll_y)))
        preview = self.owner.viewer.edit_image.denoise_preview(
            width, height, pos_x, image_pos_y)
        overlay_image = self.ids['denoiseOverlay']
        widget_pos_y = int((self.image_y * scroll_area.scroll_y) -
                           (width * scroll_area.scroll_y))
        overlay_image.pos = [pos_x, widget_pos_y]
        overlay_image._coreimage = CoreImage(preview, ext='jpg')
        overlay_image._on_tex_change()
        overlay_image.opacity = 1
    def on_sort_reverse(self, *_):
        """Updates the sort reverse button's state variable, since kivy doesnt just use True/False for button states."""

        app = App.get_running_app()
        self.sort_reverse_button = 'down' if to_bool(app.config.get('Sorting', 'album_sort_reverse')) else 'normal'