Agamnentzar / ag-psd

Javascript library for reading and writing PSD files
Other
504 stars 66 forks source link

Linked files 'name' property returning incorrectly for duplicated smart objects #178

Open Rymierymie opened 5 months ago

Rymierymie commented 5 months ago

Hey, I think I've noticed a small issue – when I create two smart objects from layers with the same name (let's use 'A' for example) in the Photoshop UI, the .psb files that are created for those smart objects would be named A.psb and 'A1.psbon my system. Photoshop would be adding the1` to avoid clashes in the file names.

The issue I'm having is when I read a PSD and access the linked files array, I get two files for my two smart object layers, but they are both given the name A.psb rather than the second being A1.psb.

I was wanting to use this name to distinguish between the smart objects in a way that would persist through changes to the PSD if I'm reading it multiple times (as the id value for these files regenerates each read I wasn't able to use that).

Agamnentzar commented 5 months ago

I checked and it seems that Photoshop is saving the same name for these files, it must be adding that extra "1" at runtime when it notices that there's a duplicate name.

Rymierymie commented 5 months ago

Interesting. Thanks for checking so quickly!

Do you mean they're just labelling that in the PS UI?

Confusing, as I can right-click the tab for the smart object when I'm editing it and "reveal (the file) in Finder" where you can see an A.psb and and A1.psb in a folder wherever PS has saved things.

But that makes sense it is just temporary files while you have PS open and editing things.

If you have any idea on how to ID a smart object across multiple reads of a document that is guaranteed (currently I'll be covering most bases, but edge cases could break) that would be much appreciated! By the looks of things all the IDs for smart objects or linked files are regenerated after a change or on a fresh read of the PSD.