diff --git a/hydrus/client/gui/canvas/ClientGUICanvas.py b/hydrus/client/gui/canvas/ClientGUICanvas.py index 5f113425..c0648ca0 100644 --- a/hydrus/client/gui/canvas/ClientGUICanvas.py +++ b/hydrus/client/gui/canvas/ClientGUICanvas.py @@ -4570,7 +4570,7 @@ class CanvasMediaListBrowser( CanvasMediaListNavigable ): ClientGUIMenus.AppendMenuItem( copy_menu, 'file_id ({})'.format( hash_id_str ), 'Copy this file\'s internal file/hash_id.', HG.client_controller.pub, 'clipboard', 'text', hash_id_str ) - if self._current_media.GetMime() in HC.IMAGES: + if self._current_media.IsImage(): ClientGUIMenus.AppendMenuItem( copy_menu, 'bitmap', 'Copy this file to your clipboard as a bitmap.', self._CopyBMPToClipboard ) diff --git a/hydrus/client/gui/canvas/ClientGUICanvasMedia.py b/hydrus/client/gui/canvas/ClientGUICanvasMedia.py index d9c77380..2a013b1e 100644 --- a/hydrus/client/gui/canvas/ClientGUICanvasMedia.py +++ b/hydrus/client/gui/canvas/ClientGUICanvasMedia.py @@ -312,9 +312,9 @@ def GetShowAction( media: ClientMedia.MediaSingleton, canvas_type: int ): action = HG.client_controller.new_options.GetMediaShowAction( mime ) - if mime == HC.APPLICATION_PSD and not HydrusPSDHandling.PSD_TOOLS_OK and action[0] == CC.MEDIA_VIEWER_ACTION_SHOW_WITH_NATIVE: + if mime == HC.APPLICATION_PSD and action[0] == CC.MEDIA_VIEWER_ACTION_SHOW_WITH_NATIVE and not HydrusPSDHandling.PSD_TOOLS_OK : - # fall back to open externally button when psd_tools not available + # fallback to open externally button when psd_tools not available action = ( CC.MEDIA_VIEWER_ACTION_SHOW_OPEN_EXTERNALLY_BUTTON, start_paused, start_with_embed ) return action diff --git a/hydrus/client/gui/pages/ClientGUIResults.py b/hydrus/client/gui/pages/ClientGUIResults.py index d64abb04..592bff31 100644 --- a/hydrus/client/gui/pages/ClientGUIResults.py +++ b/hydrus/client/gui/pages/ClientGUIResults.py @@ -178,7 +178,7 @@ class MediaPanel( CAC.ApplicationCommandProcessorMixin, ClientMedia.ListeningMed media = self._GetFocusSingleton() - if media.GetMime() in HC.IMAGES: + if media.IsImage(): HG.client_controller.pub( 'clipboard', 'bmp', ( media, resolution ) ) @@ -4297,7 +4297,7 @@ class MediaPanelThumbnails( MediaPanel ): if focused_is_local: - if self._focused_media.GetMime() in HC.IMAGES: + if self._focused_media.IsImage(): ClientGUIMenus.AppendMenuItem( copy_menu, 'bitmap', 'Copy this file to your clipboard as a bitmap.', self._CopyBMPToClipboard ) diff --git a/hydrus/core/HydrusPSDHandling.py b/hydrus/core/HydrusPSDHandling.py index 19444c9f..f18eaae5 100644 --- a/hydrus/core/HydrusPSDHandling.py +++ b/hydrus/core/HydrusPSDHandling.py @@ -19,6 +19,10 @@ except: def MergedPILImageFromPSD(path: str) -> PILImage: + + if not PSD_TOOLS_OK: + + raise Exception( 'psd_tools unavailable' ) psd = PSDImage.open(path) @@ -39,10 +43,6 @@ def MergedPILImageFromPSD(path: str) -> PILImage: def GenerateThumbnailBytesFromPSDPath(path: str, target_resolution: typing.Tuple[int, int], clip_rect = None) -> bytes: - - if not PSD_TOOLS_OK: - - raise Exception( 'psd_tools unavailable' ) pil_image = MergedPILImageFromPSD(path)