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

Read and write values into the settings of crop tool

New Here ,
Aug 05, 2008 Aug 05, 2008

Copy link to clipboard

Copied

Hi,
How can I write settings of crop tool using my script. I want to read and then to write a height, a width and a resolution in the code of script. Is it possible?
Thanks.
TOPICS
Actions and scripting

Views

481

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
Adobe
Explorer ,
Aug 05, 2008 Aug 05, 2008

Copy link to clipboard

Copied

> How can I write settings of crop tool using my script.

There is no direct way of doing this. The indirect way is to define the current
settings as a preset, save the preset to disk, then read the preset file. That
'read' part may or may not be easy. I haven't done it so I wouldn't know.


> I want to read and then to write a height, a width and a resolution in the code of script.

Why do you want to read the current values if you are just going to overwrite them?

-X
--
for photoshop scripting solutions of all sorts
contact: xbytor@gmail.com

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
New Here ,
Aug 06, 2008 Aug 06, 2008

Copy link to clipboard

Copied

In fact the aim is to avoid the constant clicking of the mouse on button that change the place of the height et width in the settings of crop tool.
As it is impossible to fix the hot-key for this button I decided to change them programmed according to the side propotion of the image.
For exemple if the width of the image is bigger than the heigth, then I put the width of the frame 15, and the height 10 and vice versa.
I wanted to read the settings in order to make the skript more flexible. But if it is difficult, I can do without it, just by inserting my values, for exemple. Is it possible to do somehow?

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
Valorous Hero ,
Aug 06, 2008 Aug 06, 2008

Copy link to clipboard

Copied

As Xbytor says the best way would be to create presets, these could then be called depending on your criteria.

Heres an example of loading a preset.



#target photoshop



if(findCurrentTool() == 'cropTool'){

SelectCropPreset("Crop 4 inch x 6 inch 300 ppi");

}else{

alert("You need to have the Crop Tool selected");

}



function SelectCropPreset(Preset) {

var desc5 = new ActionDescriptor();

var ref2 = new ActionReference();

ref2.putName( app.stringIDToTypeID('toolPreset'), Preset );

desc5.putReference( app.charIDToTypeID('null'), ref2 );

executeAction( app.charIDToTypeID('slct'), desc5, DialogModes.NO );

};



function findCurrentTool(){

var ref = new ActionReference();

ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

var cTool = typeIDToStringID(executeActionGet(ref).getEnumerationType(stringIDToTypeID('tool')));

return cTool;

};

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
New Here ,
Aug 07, 2008 Aug 07, 2008

Copy link to clipboard

Copied

Thank you very much, the script works very well, but now how instead of the warning message "You need to have the Crop Tool selected" can I make active a necessary tool automatically?

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
Valorous Hero ,
Aug 07, 2008 Aug 07, 2008

Copy link to clipboard

Copied

I haven't found a way of making the crop tool active, sorry.

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
New Here ,
Aug 07, 2008 Aug 07, 2008

Copy link to clipboard

Copied

Maybe can simply simulate pressing of a key "C" 🙂 I know, that for this used the method registerKeyPressed which is in a class javax.swing.KeyboardState. But I don't know how to make it.

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
Valorous Hero ,
Aug 07, 2008 Aug 07, 2008

Copy link to clipboard

Copied

Sorry but that is not part of Photoshop ExtendScript.

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
New Here ,
Aug 08, 2008 Aug 08, 2008

Copy link to clipboard

Copied

Understood. Many thanks for the help.

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
Valorous Hero ,
Aug 24, 2008 Aug 24, 2008

Copy link to clipboard

Copied

LATEST
Just found a way of selecting the crop tool....



selectTool('cropTool');



function selectTool(tool) {

var desc9 = new ActionDescriptor();

var ref7 = new ActionReference();

ref7.putClass( app.stringIDToTypeID(tool) );

desc9.putReference( app.charIDToTypeID('null'), ref7 );

executeAction( app.charIDToTypeID('slct'), desc9, 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