5 Replies Latest reply on Jul 29, 2013 7:30 AM by Simple Jack

    How to detect &/or delete notes in a photoshop document?

    Simple Jack Level 1

      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.

        • 1. Re: How to detect &/or delete notes in a photoshop document?
          Michael L Hale Level 5

          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.

          • 2. Re: How to detect &/or delete notes in a photoshop document?
            Michael L Hale Level 5

            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 );
            
            1 person found this helpful
            • 3. Re: How to detect &/or delete notes in a photoshop document?
              Mikaeru69 Level 3

              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

              1 person found this helpful
              • 4. Re: How to detect &/or delete notes in a photoshop document?
                Michael L Hale Level 5

                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.

                • 5. Re: How to detect &/or delete notes in a photoshop document?
                  Simple Jack Level 1

                  That works great. Thanks all for the great responses!!