Reputation: 371
When you use the crop tool there is a check box labeled, "Delete Cropped Pixels."
If you script a crop, it deletes cropped pixels. How do you disable it?
I would have expected a boolean argument but that isn't the case:
Upvotes: 0
Views: 439
Reputation: 2269
Here's an example of the ScriptingListener code wrapped in a function with the option for Delete Cropped Pixels:
crop({
left: 100,
top: 100,
right: 300,
bottom: 300,
deleteCropped: false
});
function crop(data)
{
if (data.deleteCropped == undefined) data.deleteCropped = true; // default value
var desc = new ActionDescriptor();
var descRectangle = new ActionDescriptor();
descRectangle.putUnitDouble(charIDToTypeID('Top '), charIDToTypeID('#Pxl'), data.top);
descRectangle.putUnitDouble(charIDToTypeID('Left'), charIDToTypeID('#Pxl'), data.left);
descRectangle.putUnitDouble(charIDToTypeID('Btom'), charIDToTypeID('#Pxl'), data.bottom);
descRectangle.putUnitDouble(charIDToTypeID('Rght'), charIDToTypeID('#Pxl'), data.right);
desc.putObject(charIDToTypeID('T '), charIDToTypeID('Rctn'), descRectangle);
desc.putUnitDouble( charIDToTypeID('Angl'), charIDToTypeID('#Ang'), 0.000000 );
desc.putBoolean(charIDToTypeID('Dlt '), data.deleteCropped);
executeAction(charIDToTypeID('Crop'), desc, DialogModes.NO);
} // end of crop()
Upvotes: 3