• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How change Photoshop Preferences by script (Resize Image During Place)

Participant ,
Nov 23, 2021 Nov 23, 2021

Copy link to clipboard

Copied

I'm working on some prepare scripts and I noticed on some pc's the resolution wasn't correct.

After some investigation I discovered the settings "resize image during place" that was turned on, messing up the prepare process.

Is it posible to set these kind of settings by script?

It's hard to make sure everyone is using the same settings, so forcing it automatically would be best.

TOPICS
Actions and scripting

Views

605

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
community guidelines

correct answers 4 Correct answers

LEGEND , Nov 23, 2021 Nov 23, 2021
sTT =  stringIDToTypeID;

(ref = new ActionReference()).putProperty(sTT('property'), gP = sTT('generalPreferences'))
ref.putClass(sTT('application')); (dsc1 = new ActionDescriptor()).putReference(sTT('null'), ref);
(dsc2 = new ActionDescriptor()).putBoolean(sTT('resizePastePlace'), false)
dsc1.putObject(sTT('to'), gP, dsc2), executeAction(sTT('set'), dsc1);

Votes

Translate

Translate
Community Expert , Nov 23, 2021 Nov 23, 2021

Even if you set  the Preference  to not resize during Place. Place will scale the smart object if the Image File's resolution is not the same as the document the image is being placed into.   So the  the smart object layer image size will not be the same as the Image files the smart object will be scaled.  So when your script Place in an image if resize during place scaled the smart object to fit on canvas after you place the image  you can do a  resize layer to 100%  the layer size will be the

...

Votes

Translate

Translate
Community Expert , Nov 23, 2021 Nov 23, 2021

For completeness, this can also be recorded via scriptinglistener plugin (sample below in a function) or even recorded into an action and converted to script using xtools, so we are blessed with multiple options!

 

skipTransformPlace(false); // or true

function skipTransformPlace(skipTransformSOFromLibrary) {
	var s2t = function (s) {
		return app.stringIDToTypeID(s);
	};
	var descriptor = new ActionDescriptor();
	var descriptor2 = new ActionDescriptor();
	var reference = new ActionReference();
...

Votes

Translate

Translate
LEGEND , Nov 24, 2021 Nov 24, 2021

Votes

Translate

Translate
Adobe
LEGEND ,
Nov 23, 2021 Nov 23, 2021

Copy link to clipboard

Copied

sTT =  stringIDToTypeID;

(ref = new ActionReference()).putProperty(sTT('property'), gP = sTT('generalPreferences'))
ref.putClass(sTT('application')); (dsc1 = new ActionDescriptor()).putReference(sTT('null'), ref);
(dsc2 = new ActionDescriptor()).putBoolean(sTT('resizePastePlace'), false)
dsc1.putObject(sTT('to'), gP, dsc2), executeAction(sTT('set'), dsc1);

Votes

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
community guidelines
Community Expert ,
Nov 23, 2021 Nov 23, 2021

Copy link to clipboard

Copied

Even if you set  the Preference  to not resize during Place. Place will scale the smart object if the Image File's resolution is not the same as the document the image is being placed into.   So the  the smart object layer image size will not be the same as the Image files the smart object will be scaled.  So when your script Place in an image if resize during place scaled the smart object to fit on canvas after you place the image  you can do a  resize layer to 100%  the layer size will be the size  that Place scale the image file  to. And you can get its bounds and do the resize you want to do.  If the are trying the get the size of the actual place in file image size  you need to set the document resolution to the same resolution the Image file has. Place will boe the scale the object tor the layer.  In all cases Photoshop created the hardened smart Object pixels the sane as Image Files pixels.    Place will always scale the object for the layer if the resolution do not match

JJMack

Votes

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
community guidelines
Community Expert ,
Nov 23, 2021 Nov 23, 2021

Copy link to clipboard

Copied

For completeness, this can also be recorded via scriptinglistener plugin (sample below in a function) or even recorded into an action and converted to script using xtools, so we are blessed with multiple options!

 

skipTransformPlace(false); // or true

function skipTransformPlace(skipTransformSOFromLibrary) {
	var s2t = function (s) {
		return app.stringIDToTypeID(s);
	};
	var descriptor = new ActionDescriptor();
	var descriptor2 = new ActionDescriptor();
	var reference = new ActionReference();
	reference.putProperty( s2t( "property" ), s2t( "generalPreferences" ));
	reference.putEnumerated( s2t( "application" ), s2t( "ordinal" ), s2t( "targetEnum" ));
	descriptor.putReference( s2t( "null" ), reference );
	descriptor2.putBoolean( s2t( "extensionsOn" ), true );
	descriptor2.putBoolean( s2t( "skipTransformSOFromLibrary" ), skipTransformSOFromLibrary );
	descriptor2.putBoolean( s2t( "modernFreeTransform" ), true );
	descriptor.putObject( s2t( "to" ), s2t( "generalPreferences" ), descriptor2 );
	executeAction(s2t( "set" ), descriptor, DialogModes.NO);
}

 

 

Votes

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
community guidelines
Participant ,
Nov 24, 2021 Nov 24, 2021

Copy link to clipboard

Copied

Great work you guys! All very usefull stuff! Turning off "resize on place" is enough in my case.

To keep a long story short.. I made an extension with many functions, one is preparing a psd (folder stucture and loading in .ai files). These files are always 300 dpi, and the psd template I start with is also 300 dpi. When I load the template, the canvas is 2000x2000 by default. When I place an ai file as smart object, it normally places it in the middle of de template psd, and by reading out layer data I can figure out the dimensions of the ai inside the template psd, for example 8000x3400, and resize the template including some margin accordingly.

It works great as long as the "resize on place" is turned off, or else it scales to fit the canvas of 2000x2000.

I added a function that turns this option off every time the extension is loaded, and it works great!

 

Great to know these settings can also be captured by script listener, didn't know that!

 

I also need to change a setting in the "panel options" called "Add 'copy' to Copied Layers and Groups".

I don't see anything usefull in scriptlistener in this case. Maybe these panel options cannot be set by script?

Votes

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
community guidelines
LEGEND ,
Nov 24, 2021 Nov 24, 2021

Copy link to clipboard

Copied

Votes

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
community guidelines
Participant ,
Nov 25, 2021 Nov 25, 2021

Copy link to clipboard

Copied

LATEST

Works perfect!

Votes

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
community guidelines