Skip to content

Conversation

@cromachina
Copy link
Contributor

Fixes #325

@cromachina
Copy link
Contributor Author

I have made it so that clipping on to a pass through layer causes no clipping to occur, which is the same behavior as SAIv2 and CSP. However it seems like this is not correct according to Photoshop, because it's causing a test to fail where a layer is clipped onto a pass through group.

@cromachina cromachina marked this pull request as ready for review September 30, 2022 13:49
@cromachina
Copy link
Contributor Author

I can probably add a flag to PSDImage for compatibility modes like enum { PS, SAI, CSP = SAI, GIMP = PS, KRITA = PS } and whatever else is out there.

@kyamagu
Copy link
Contributor

kyamagu commented Oct 3, 2022

@cromachina What would be the test to check the correctness?

@cromachina
Copy link
Contributor Author

@kyamagu I don't have Photoshop so it's hard for me to confirm, but the test test_layers.test_clip_adjustment seems to be the offending one. From what I can infer from this test, it seems like in PS you can clip on to a PASS_THROUGH layer, but in SAI, the clipping behavior is ignored. The former would look like "source atop" and the latter would look like "source over". Does this sound correct?

self._record = data
self._layers = []
self._tagged_blocks = None
self._compatibility_mode = CompatibilityMode.DEFAULT
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, there is VersionInfo field in the resource section of a PSD file, that states the file creator like Adobe Photoshop. Perhaps this part should attempt at guessing the default compatibility mode.

from psd_tools.constants import Resource
version_info = psd.image_resources.get_data(Resource.VERSION_INFO)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can try something like that in bit.

from enum import Enum, IntEnum
from enum import Enum, IntEnum, auto

class CompatibilityMode(Enum):
Copy link
Contributor

Choose a reason for hiding this comment

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

Presumably there should be fixture files to test those. Any possibility?

layer._clip_layers = []
layer._has_clip_target = True

def _compute_clipping_layers(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Appreciate if there is a short comment describing the behavior difference between tools

@kyamagu kyamagu merged commit 0876756 into psd-tools:main Dec 22, 2022
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.

Group clipping into layer causes RecursionError

2 participants