diff --git a/ppl2psd.py b/ppl2psd.py index 1a269e9..77a36e8 100644 --- a/ppl2psd.py +++ b/ppl2psd.py @@ -741,15 +741,25 @@ def convert(ppl_path: str, out_path: str, preview_path: Optional[str] = None, g = group_map.get(gid) if not g or "boundingRect" not in g: continue - gl, gt, _, _ = bounding_rect(g) + gl, gt, gr, gb = bounding_rect(g) # only this group's OWN layers (nested groups' layers excluded) own = [i for i in range(first, last + 1) if layers[i].get("groupId") == gid] if not own: continue - inner_l = min(bounding_rect(layers[i])[0] for i in own) - inner_t = min(bounding_rect(layers[i])[1] for i in own) - group_offset[gid] = (gl - inner_l, gt - inner_t) + rects = [bounding_rect(layers[i]) for i in own] + inner_l = min(r[0] for r in rects) + inner_t = min(r[1] for r in rects) + inner_r = max(r[2] for r in rects) + inner_b = max(r[3] for r in rects) + # If the group bbox fully contains its content, the children sit + # at their ppl coordinates (the bbox is just a bigger frame, e.g. + # group_64). Only offset when the group was moved away from its + # content (bbox disjoint, e.g. groups 169/181). + if gl <= inner_l and gt <= inner_t and gr >= inner_r and gb >= inner_b: + group_offset[gid] = (0, 0) + else: + group_offset[gid] = (gl - inner_l, gt - inner_t) rendered = [] skipped = 0