Copy link to clipboard
Copied
I want to achieve a task where I need to place a file in photoshop through JSX script.
const idplaceEvent = stringIDToTypeID("placeEvent");
const desc22 = new ActionDescriptor();
const idID = stringIDToTypeID("ID");
desc22.putInteger(idID, 8);
const idnull = stringIDToTypeID("null");
desc22.putPath(idnull, new File(filePath));
let idlinked = stringIDToTypeID( "linked" );
desc22.putBoolean( idlinked, true );
const idfreeTransformCenterState = stringIDToTypeID("freeTransformCenterState");
const idquadCenterState = stringIDToTypeID("quadCenterState");
const idQCSAverage = stringIDToTypeID("QCSAverage");
desc22.putEnumerated(idfreeTransformCenterState, idquadCenterState, idQCSAverage);
let idoffset = stringIDToTypeID("offset");
const desc23 = new ActionDescriptor();
const idhorizontal = stringIDToTypeID("horizontal");
let idpixelsUnit = stringIDToTypeID("pixelsUnit");
desc23.putUnitDouble(idhorizontal, idpixelsUnit, 0.000000);
const idvertical = stringIDToTypeID("vertical");
idpixelsUnit = stringIDToTypeID("pixelsUnit");
desc23.putUnitDouble(idvertical, idpixelsUnit, 0.000000);
idoffset = stringIDToTypeID("offset");
desc22.putObject(idoffset, idoffset, desc23);
executeAction(idplaceEvent, desc22, DialogModes.NO);
After this I can relink the active layer through script itself, but doing this, it increasing the size of layer way too much.
let idselect = stringIDToTypeID( "select" );
let desc4 = new ActionDescriptor();
let idnull = stringIDToTypeID( "null" );
let ref2 = new ActionReference();
let idlayer = stringIDToTypeID( "layer" );
ref2.putName( idlayer, layerName );
desc4.putReference( idnull, ref2 );
let idmakeVisible = stringIDToTypeID( "makeVisible" );
desc4.putBoolean( idmakeVisible, false );
let idlayerID = stringIDToTypeID( "layerID" );
let list2 = new ActionList();
list2.putInteger( 2 );
desc4.putList( idlayerID, list2 );
executeAction(idselect, desc4, DialogModes.NO);
let idplacedLayerRelinkToFile = stringIDToTypeID( "placedLayerRelinkToFile" );
let desc3 = new ActionDescriptor();
desc3.putPath( idnull, new File(placementFilepath) );
executeAction(idplacedLayerRelinkToFile, desc3, DialogModes.NO);
Is it possible to keep the layer size same if i relink the layer?
Thanks in advance
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thanks @r-bin. I checked the same. It does not happen when I do it from the app itself. Just not working while doing from the script.
Copy link to clipboard
Copied