Hi Vijay, sounds like you’re on the right track. When images land on the correct layer but don’t line up with the frame, that usually means the transform step is firing before Photoshop has fully registered the placed layer geometry.
Photoshop’s manual Place command does a few things in a very strict order. If your batchPlay sequence deviates even slightly, you get the oversize or off centre behaviour you’re seeing.
The usual reliable sequence looks like this:
- Place the file and convert it to a smart object straight away
- Wait for Photoshop to finish the placement event
- Read the frame layer’s bounds
- Transform the smart object to match those bounds
- Apply the clipping mask last
A lot of plugins get tripped up by step 2. batchPlay fires instantly, but Photoshop is still calculating the smart object’s natural size. If you transform before the metadata is ready, you get nonsense scale values.
A minimal pattern that works is something like:
- batchPlay place event
- batchPlay convert to smart object
- await a small artificial pause using executeAsModal and an async wrapper
- batchPlay transform using frame.bounds
- batchPlay set clipping mask
No need for huge delays, even a micro task is enough to let PS settle before the transform.
If you want a working example to study, the UXP Samples repo on Github has a clipping mask example that shows the correct event order. It’s not plug and play for your case, but the structure is the bit that matters.
Once you follow that exact order you should get the same behaviour as manual Place Embedded every time.
Good luck with the plugin, you’re very close.