Copy link to clipboard
Copied
I use this function to resize a selection and to stop (DialogModes.ALL) on the resize object.
When it's done, just dobble-click it and that's it.
But...
some times I just don't want to make any change to resize and I just go directly to the dobble-click: this generates an error and doesn't crop.
It forces me to resize even when I don't want to.
Can you help me?
//select something
cropDialog();
function cropDialog() {
var idTrnf = charIDToTypeID( "Trnf" );
var desc19 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref11 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idfsel = charIDToTypeID( "fsel" );
ref11.putProperty( idChnl, idfsel );
desc19.putReference( idnull, ref11 );
var idFTcs = charIDToTypeID( "FTcs" );
var idQCSt = charIDToTypeID( "QCSt" );
var idQcsa = charIDToTypeID( "Qcsa" );
desc19.putEnumerated( idFTcs, idQCSt, idQcsa );
var idOfst = charIDToTypeID( "Ofst" );
var desc20 = new ActionDescriptor();
var idHrzn = charIDToTypeID( "Hrzn" );
var idPxl = charIDToTypeID( "#Pxl" );
desc20.putUnitDouble( idHrzn, idPxl, 0.000000 );
var idVrtc = charIDToTypeID( "Vrtc" );
var idPxl = charIDToTypeID( "#Pxl" );
desc20.putUnitDouble( idVrtc, idPxl, 0.000000 );
var idOfst = charIDToTypeID( "Ofst" );
desc19.putObject( idOfst, idOfst, desc20 );
var idWdth = charIDToTypeID( "Wdth" );
var idPrc = charIDToTypeID( "#Prc" );
desc19.putUnitDouble( idWdth, idPrc, 100.000000 );
var idHght = charIDToTypeID( "Hght" );
var idPrc = charIDToTypeID( "#Prc" );
desc19.putUnitDouble( idHght, idPrc, 100.000000 );
var idLnkd = charIDToTypeID( "Lnkd" );
desc19.putBoolean( idLnkd, true );
executeAction( idTrnf, desc19, DialogModes.ALL ); // em vez de DialogModes.NO, ou seja, para parar
}
Change..
executeAction( idTrnf, desc19, DialogModes.ALL );
To
try{
executeAction( idTrnf, desc19, DialogModes.ALL );
}catch(e){}
Copy link to clipboard
Copied
Change..
executeAction( idTrnf, desc19, DialogModes.ALL );
To
try{
executeAction( idTrnf, desc19, DialogModes.ALL );
}catch(e){}
Copy link to clipboard
Copied
Is that all of your code?. What you posted is just a transform selection function, it doesn't crop. However if you want to be able to accept the current selection without resizing just put the executeAction in a try/catch block.
cropDialog();
function cropDialog() {
var idTrnf = charIDToTypeID( "Trnf" );
var desc19 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref11 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idfsel = charIDToTypeID( "fsel" );
ref11.putProperty( idChnl, idfsel );
desc19.putReference( idnull, ref11 );
var idFTcs = charIDToTypeID( "FTcs" );
var idQCSt = charIDToTypeID( "QCSt" );
var idQcsa = charIDToTypeID( "Qcsa" );
desc19.putEnumerated( idFTcs, idQCSt, idQcsa );
var idOfst = charIDToTypeID( "Ofst" );
var desc20 = new ActionDescriptor();
var idHrzn = charIDToTypeID( "Hrzn" );
var idPxl = charIDToTypeID( "#Pxl" );
desc20.putUnitDouble( idHrzn, idPxl, 0.000000 );
var idVrtc = charIDToTypeID( "Vrtc" );
var idPxl = charIDToTypeID( "#Pxl" );
desc20.putUnitDouble( idVrtc, idPxl, 0.000000 );
var idOfst = charIDToTypeID( "Ofst" );
desc19.putObject( idOfst, idOfst, desc20 );
var idWdth = charIDToTypeID( "Wdth" );
var idPrc = charIDToTypeID( "#Prc" );
desc19.putUnitDouble( idWdth, idPrc, 100.000000 );
var idHght = charIDToTypeID( "Hght" );
var idPrc = charIDToTypeID( "#Prc" );
desc19.putUnitDouble( idHght, idPrc, 100.000000 );
var idLnkd = charIDToTypeID( "Lnkd" );
desc19.putBoolean( idLnkd, true );
try{
executeAction( idTrnf, desc19, DialogModes.ALL ); // em vez de DialogModes.NO, ou seja, para parar
}catch(e){}
}
But it still will not crop without additional code.
Copy link to clipboard
Copied
It is not all the code. I have passed only a portion.
Thanks!