From 4fcc5acc8542f0b349f49d471849b83c7694966c Mon Sep 17 00:00:00 2001 From: AskaEth Date: Thu, 27 Aug 2026 15:51:15 +0800 Subject: [PATCH] Only apply group offset when bbox is disjoint from content The app only moves group children when the group bbox is disjoint from its content (group moved away, e.g. groups 169/181). When the bbox contains the content (e.g. group_64 with a taller frame), children stay at their ppl coordinates. Fixes group_64 being shifted up 1225px. --- ppl2psd.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) 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