Skip to content

Commit

Permalink
Update gallery_viewer_script.py
Browse files Browse the repository at this point in the history
  • Loading branch information
burghoff committed Oct 13, 2024
1 parent 3e5a35a commit 5d5acee
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions scientific_inkscape/gallery_viewer_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,8 @@ def run(self):
width, height = im.size
new_width = 400
new_height = int((new_width / width) * height)
if 'info' in im.__dict__ and "dpi" in im.info and isinstance(im.info["dpi"],tuple) and len(im.info["dpi"]) == 2:
new_height = int((new_width / width * im.info["dpi"][0]/im.info["dpi"][1]) * height)
resized_image = im.resize((new_width, new_height), Image.LANCZOS)
resized_image.save(conversion_path)

Expand All @@ -402,13 +404,13 @@ def run(self):
nattempts += 1

# Trigger a refresh and update the converted files dictionary
trigger_refresh()
converted_files[hashed] = self.fileout
else:
# If already converted, copy the existing file
shutil.copy2(converted_files[hashed], self.fileout)
if os.path.exists(self.fileout):
self.thumbnails[self.index] = self.fileout
trigger_refresh()
self.done = True


Expand Down Expand Up @@ -806,7 +808,6 @@ def convert_emfs(self):


def run(self):
self.run_on_fof()
global myapp
if myapp is None:
myapp = True
Expand All @@ -817,9 +818,9 @@ def run(self):
if not (openedgallery):
webbrowser.open("http://localhost:{}".format(str(PORTNUMBER)))
openedgallery = True
else:
trigger_refresh()
self.convert_emfs()
self.run_on_fof()
trigger_refresh()
self.convert_emfs() # already refreshes

def get_modtimes():
modtimes = dict()
Expand Down Expand Up @@ -969,7 +970,7 @@ def on_button_clicked(self, widget):

def on_file_button_clicked(self, widget):
native = Gtk.FileChooserNative.new(
"Please choose files", self, Gtk.FileChooserAction.OPEN, None, None
"Please choose one or more files", self, Gtk.FileChooserAction.OPEN, None, None
)
native.set_select_multiple(True)
filter_ppt = Gtk.FileFilter()
Expand All @@ -990,7 +991,7 @@ def on_file_button_clicked(self, widget):

def on_folder_button_clicked(self, widget):
native = Gtk.FileChooserNative.new(
"Please choose a file or directory",
"Please choose one or more directories",
self,
Gtk.FileChooserAction.SELECT_FOLDER,
None,
Expand Down

0 comments on commit 5d5acee

Please sign in to comment.