Copy link to clipboard
Copied
I have lots of files that when I crop them they need to a specific ratio. Currently they are saved to the tool.
I would like to be able to make a shortcut so that it selects the crop tool and selects the ratio from the File name. I can gather the info from the filename.
i.e. FR10 = a Ratio of 2:3
or
DE20 = 3:4
It does not need to crop the image just select the tool.
I found this to select the tool
The beginning is like this.
if (app.documents.length > 0) {
var myDocument = activeDocument;
var fileNameNoExtension = myDocument.name;
fileNameNoExtension = fileNameNoExtension.split( "." );
if ( fileNameNoExtension.length > 1 ) {
fileNameNoExtension.length--;
}
fileNameNoExtension = fileNameNoExtension.join(".");
var BrandString = fileNameNoExtension.substr(0,4);
}
if (/^(FR10|WA35)$/.exec(BrandString)){
var the_x_Ratio =2
var the_y_Ratio =3
}
...
// 2016, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var width = myDocument.width;
var height = myDocument.height;
var rel = 1;
if (myDocument.name.indexOf("AB10") != -1) {var rel = 0.666};
if (myDocument.name.indexOf("CD10") != -1) {var rel = 0.75};
if (myDocument.name.indexOf("EF10") != -1) {var rel = 0.8};
if (myDocument.name.indexOf("CH10") !
Copy link to clipboard
Copied
OK So I have popped this into the top of the original script
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var applicationDesc = executeActionGet(ref);
var currentToolOpt = applicationDesc.getObjectValue(stringIDToTypeID("currentToolOptions"));
var settings = currentToolOpt.getObjectValue(currentToolOpt.getKey(0));
var previouswidth (settings.getUnitDoubleValue(settings.getKey(3)));
var previousheight (settings.getUnitDoubleValue(settings.getKey(5)));
Then after all my if statements added the else like lie so,
if (myDocument.name.indexOf("WA35") != -1) {var rel = (2/3)};
if (myDocument.name.indexOf("MM__") != -1) {var rel = (1500/2000)};
else {var rel = (previouswidth/previousheight)};
Obviously not working how do I write the else if nothing fits then use previous?
Copy link to clipboard
Copied
Why keys 3 and 5?
Don’t you need 1 and 2?
Copy link to clipboard
Copied
3 and 5 match those entered in the ratio.
Copy link to clipboard
Copied
I would like to know if it is possible to have the 16x9 ratio
Copy link to clipboard
Copied
No one can help me with the horizontal crop
Copy link to clipboard
Copied
No one can help me with the horizontal crop
What is the problem?
Have you tried amending the Script?
Copy link to clipboard
Copied
I did various tests but I did not have any luck
I would like the crop to be horizontal as in the figure above
thank you
Copy link to clipboard
Copied
Quite frankly I think you should start a new thread and post the code you have issues with instead of adding to some old thread.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now