Copy link to clipboard
Copied
I'm using C# to batch process .psd files and extract jpeg's in various formats and sizes. However, the SaveAs hangs whenever a psd contains a note. I solved a similar hang condition due to alpha channels in the document by porting a script solution, but I can't see any way of deleting, enumerating, or even detecting notes in a photoshop document object.
Can anyone tell me how to do deal with notes?
I hope this is the correct forum for this question.
Thanks in advance.
Copy link to clipboard
Copied
I have never had any luck working with the open document using javascript. I can't find any useful Action Descriptor keys for this.
I can say that you can determine if the file has notes before you open it by searching the file for the string "8BIMAnno". And saving notes is one of the Photoshop save options. So you should be able to search the file for the notes tag and if found - open, save without the notes, close, and open noteless version.
Copy link to clipboard
Copied
Does C# not let you save as a copy? This Action Manger saves a document with notes as a jpeg( it strips out the notes durning the save )
var idsave = charIDToTypeID( "save" );
var desc813 = new ActionDescriptor();
var idAs = charIDToTypeID( "As " );
var desc814 = new ActionDescriptor();
var idEQlt = charIDToTypeID( "EQlt" );
desc814.putInteger( idEQlt, 12 );
var idMttC = charIDToTypeID( "MttC" );
var idMttC = charIDToTypeID( "MttC" );
var idNone = charIDToTypeID( "None" );
desc814.putEnumerated( idMttC, idMttC, idNone );
var idJPEG = charIDToTypeID( "JPEG" );
desc813.putObject( idAs, idJPEG, desc814 );
var idIn = charIDToTypeID( "In " );
desc813.putPath( idIn, new File( "C:\\Users\\User\\Desktop\\spotChannels.jpg" ) );
var idDocI = charIDToTypeID( "DocI" );
desc813.putInteger( idDocI, 1210 );
var idCpy = charIDToTypeID( "Cpy " );
desc813.putBoolean( idCpy, true );// SaveAs copy
var idsaveStage = stringIDToTypeID( "saveStage" );
var idsaveStageType = stringIDToTypeID( "saveStageType" );
var idsaveSucceeded = stringIDToTypeID( "saveSucceeded" );
desc813.putEnumerated( idsaveStage, idsaveStageType, idsaveSucceeded );
executeAction( idsave, desc813, DialogModes.NO );
Copy link to clipboard
Copied
In case you still want to delete all notes in a photoshop document, the following code should do the trick (works for me in CS and CS4):
try
{
executeAction (stringIDToTypeID ("deleteAllAnnot"));
}
catch (e)
{
}
HTH,
-- Mikaeru
Copy link to clipboard
Copied
Thanks, that works in CC as well. And it doesn't seem to need the try/catch block. At least in CC it will not throw an error if there are no notes.
Copy link to clipboard
Copied
That works great. Thanks all for the great responses!!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now