Highlighted

Relinking files in photoshop changes layer dimension

New Here ,
Sep 05, 2020

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
 

TOPICS
Actions and scripting, How to, Mac, SDK, Windows

Views

63

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Relinking files in photoshop changes layer dimension

New Here ,
Sep 05, 2020

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
 

TOPICS
Actions and scripting, How to, Mac, SDK, Windows

Views

64

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 05, 2020 0
Adobe Community Professional ,
Sep 05, 2020

Copy link to clipboard

Copied

File size and resolution must be the same. Then the layer size will be preserved.
Only Photoshop CS2 allowed not to change the size of the smart object when replacing content.
Then some smart guy didn't like it and they decided to redo it as it works now.
You need to transform the smart object after the Relink command to the dimensions that were before this operation.
Everything would be fine, but sometimes the size of the layer after Relink (Replace) can turn out to be so gigantic that you may simply not have enough memory to perform the transformation, and a lot of time will be spent on it.
 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 05, 2020 2
New Here ,
Sep 05, 2020

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.

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 05, 2020 0
r-bin LATEST
Adobe Community Professional ,
Sep 06, 2020

Copy link to clipboard

Copied

Can not reproduce.
Could you give more details.
Which version of Photoshop, in particular?

How do you run this script?
The fact is that in jsx it is unacceptable to use the word "let" instead of "var". This is a syntax error and your script will not run.
 
UPD. What types of files do you use for Relink?
 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 06, 2020 0