Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper PSD support #498

Merged
merged 14 commits into from
Oct 1, 2022
Merged

Proper PSD support #498

merged 14 commits into from
Oct 1, 2022

Conversation

RvanderLaan
Copy link
Collaborator

Added an ImageLoader for PSD files based on ag-psd

  • It runs in a web worker so it shouldn't impact performance much, except maybe that reading the files still happens in the main thread. PSDs can be big. Could also read files in the worker but that doesn't fit in the current image loading architecture
  • It works fine for a dozen PSDs of 3K to 4K resolution on my machine, although they do take a few seconds to load
  • Also added a check to re-create thumbnails if the original file was modified after creating the thumbnail

Closes #496

@Krakor92
Copy link
Contributor

Krakor92 commented Aug 1, 2022

Thank you very much for this quick answer!

I tried it and I must say it works very well. I'm really impressed that even with heavy psd files it loads them relatively fast and the quality when double-clicking is very good 😄
Also, the change of thumbnail on the files that have been updated is the icing on the cake ✨

While testing it, I've noticed a few flaws that I've tried to debug, but I think they're related to things that are too deep in the code base for me to simply fix:

So I got different results on the generated thumbnails depending on the psd properties, but all of them looked fine when I double-clicked on them.

Image 1

  1. The first case concerns .psd files that were already in my location before I tried this pr:
    These are strange because they keep their original low-resolution thumbnail but when I double-click on them, I can see their real size (instead of their thumbnail size as before).

  2. The second case concerns relatively small .psd (~50 Mb or below) that i've just put in my location folder:
    All their thumbnails are square and middle centered. You cannot read their size in the metadata panel (when you double-click on them).

Image 2

  1. Finally, the last case concerns heavy .psd files (~more than 50 Mb) whose thumbnails are broken at the beginning (like the first one in the first picture), but after reloading Allusion, they appear as the second ones.

So, at the moment, you can't have both a decent quality thumbnail with a correct aspect ratio AND actual dimensions in its info panel.
(Actually, you can, but it's mostly a workaround).

I also noticed that the thumbnails generated for the psd files in the ".../AppData/Local/Temp/Allusion/thumbnails" directory are larger than the others. Reading the code, I noticed that you set the size of the largest dimension to 600px, but strangely, on the new psd thumbnails, it's their smallest dimension that is set to 600px (is this intended?).

Image 3


Ps: I think I found a bug (although it seems to be on the ag-psd side) that occurs when you have at least one custom selection stored in the channel tab of your psd. Even if it is not checked, the generated thumbnail will be masked based on the first top custom layer in that tab (I don't think this is a feature). A simple solution is to generate a saved selection of your entire canvas and place it above your custom layers in the channel tab.

(You can see in the image below the behavior of Allusion based on the state of the psd's channel tab)

Image 4

This will force Allusion to recreate the psd thumbnail with intended transparency, correct aspect ratio and actual dimensions in the info panel.
(Allusion will also recreate a thumbnail in the correct format when you delete a visible layer containing content.)

@Krakor92
Copy link
Contributor

Krakor92 commented Aug 2, 2022

You can also remove the tooltip next to the psd checkbox in the Image formats menu as it works fine now 👍

image

@hummingly
Copy link
Collaborator

hummingly commented Aug 2, 2022

Sorry I missed the notification as I am being flooded from work notification. I will take a look in the evening.

Copy link
Collaborator

@hummingly hummingly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Regarding performance, I think the way we use threads needs some overhaul anyways but web workers do not make it so easy 😅

@RvanderLaan
Copy link
Collaborator Author

Thanks for taking a close look @Krakor92 !

  1. Good point, we could add a migration step when updating to this version that clears the old PSD thumbnails. We don't have something in place for this yet, might be more difficult than expected
  2. We're currently relying on exiftool for detecting the resolution of images, which should be able to extract it for PSDs too according to https://exiftool.org/TagNames/Photoshop.html
    But if that turns out not to reliably work in practice, we could add a fallback so save the resolution we know after creating a thumbnail. Then it'll still appear square at first
  3. I've seen that happening for other types of images too, which we did put out some fixes for. I'll have a look to see whether there are any errors popping up specifically for PSDs 👍
    That thumbnail size issue isn't intentional, will take a look at that too

Nice catch on that last one, sounds like it's worth a bug report over there 😃

@RvanderLaan
Copy link
Collaborator Author

I've had a quick look around, but I can't find a robust way to trigger logic after upgrading an Electron application (for deleting low res psd thumbnails). We could also just tell people to delete their thumbnail folder in the release notes if it bothers them, then they'll be recreated

@RvanderLaan
Copy link
Collaborator Author

Sorry it's taking so long to get released, life got in the way... I'm going to try my best to get it done this weekend!

@RvanderLaan RvanderLaan merged commit cef4d09 into master Oct 1, 2022
@RvanderLaan RvanderLaan deleted the better-psd-support branch October 1, 2022 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improved and more reliable PSD support
3 participants