Reputation:
I've spent the last day and a half rendering some complex math graphics into hundreds of files and only realise now that I forgot to remove a small white box from the bottom right of the images!
So I was hoping to automate the fix. I have been able to use the content-aware fill in photoshop cs5 by hand to remove it and would like to write a javascript script to do it for the many hundreds of others.
However, in the javascript reference for Selection.fill(...) the filltype argument is of type SolidColor. Is this the only way to use a fill? Strangely, a search for content aware in this document comes up with nothing so is this feature not scriptable? I haven't had any luck searching for this online, perhaps because there's so much stuff coming up with people saying how amazing the feature is that it's drowning out any scripting results.
Thanks!
Upvotes: 2
Views: 1627
Reputation: 2269
Here's Action Manager code you'll see in ScriptingListener.log:
// =======================================================
var idFl = charIDToTypeID( "Fl " );
var desc62295 = new ActionDescriptor();
var idUsng = charIDToTypeID( "Usng" );
var idFlCn = charIDToTypeID( "FlCn" );
var idcontentAware = stringIDToTypeID( "contentAware" );
desc62295.putEnumerated( idUsng, idFlCn, idcontentAware );
var idOpct = charIDToTypeID( "Opct" );
var idPrc = charIDToTypeID( "#Prc" );
desc62295.putUnitDouble( idOpct, idPrc, 100.000000 );
var idMd = charIDToTypeID( "Md " );
var idBlnM = charIDToTypeID( "BlnM" );
var idNrml = charIDToTypeID( "Nrml" );
desc62295.putEnumerated( idMd, idBlnM, idNrml );
executeAction( idFl, desc62295, DialogModes.NO );
It's kinda scary but it can be easily modified to something like that:
function contentAwareFill() {
//works only with selection
try {var SB = activeDocument.selection.bounds}
catch (e) {alert('content aware fill needs a selection'); return};
//100% opacity, normal blending content aware fill
var desc = new ActionDescriptor();
desc.putEnumerated( charIDToTypeID( "Usng" ), charIDToTypeID( "FlCn" ), stringIDToTypeID( "contentAware" ) );
executeAction( charIDToTypeID( "Fl " ), desc, DialogModes.NO );
}
Upvotes: 2
Reputation: 2033
The Photoshop Scripting DOM (Document Object Model) doesn't have direct support for a lot of Photoshop's newer features. However, you can still access those features from scripts by creating the action descriptors for them and executing the events directly.
How do you figure out what the proper descriptor formats and events? By looking at the output of a Plug-in called ScriptListener. When the ScriptListener plug-in is installed, a log file is created on your desktop recording all of the actions you take in Photoshop as executable ExtendScript code. Launch Photoshop with ScriptListener installed, perform the operations you want to code up, and examine the contents of the log on your desktop to find the appropriate ActionDescriptors and events.
The ScriptListener plugin is posted on the Photoshop Developer Center.
Upvotes: 0
Reputation: 3131
Perhaps do this with an action in photosho instead and record the process... then batch play on the folder to reprocess all of images??
If you are unfamiliar with it open the actions panel from the window pull down and create a new action (page icon in the action panel). Now simply record
the steps you want to process and then hit the stop buttom when finished.
Once the action is recorded you can go to the batch process menu and cycle the action across an entire folder of images.
If your solution existed once within photoshop why reinvent the wheel? Using existing tools could assist the ROI on time spent during the production process.
Upvotes: 0