photoshop_distort_layer
Pin a layer's bounding box to four target corners for headless perspective or corner-pin distortion, replacing modal Free Transform → Distort. Rasterize Smart Objects first.
Instructions
Corner-pin / perspective distort of a layer: map its bounding box to four target corners (absolute document pixels, clockwise from top-left). Headless replacement for Free Transform → Distort / Perspective Warp (which are modal and cannot be scripted). Implemented as a custom warp mesh fitted to the homography — exact on pixel layers; a Smart Object must be rasterized first (rasterize:true, destructive — duplicate it before if the original matters). Read the current bounds with get_layers / get_state, then compute the target corners. Save a copy of the document before (save_document).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | perspective — true projective mapping (parallel lines converge); bilinear — straight edges, no convergence | perspective |
| layer | No | layer name (searched recursively); default — active layer | |
| corners | Yes | Target corners in absolute document px: {"tl":[x,y],"tr":[x,y],"br":[x,y],"bl":[x,y]} or a flat array [x1,y1,x2,y2,x3,y3,x4,y4] (tl,tr,br,bl) | |
| rasterize | No | rasterize a Smart Object layer before warping (destructive; required for Smart Objects) | |
| document_id | No | Optional Photoshop document id from photoshop_get_state / photoshop_list_documents. When set, the tool activates that document before running so a UI tab switch cannot retarget the edit. | |
| interpolation | No | bicubic |