6 Replies Latest reply on Apr 10, 2013 1:41 AM by LordSiegfried

    How to strip EXIF data by scripting?

    andyg543210

      Hi,

       

      Does anyone know how to strip EXIF data (camera data) via scripting?

       

      I know I can strip data by using "Save For Web", but that won't do, because save for web only exports at 72dpi, and I need my stripped file at 300dpi.

       

      I don't want to open the exported file and save it again, as that would be compressing the file twice.

       

      It would be nice to be able to this via scripts.

       

      Any way of doing it other than running "exiftool" on the file from within the script?

       

      Basically, the aim of what i am doing is, is exporting (or saving a copy) of a JPEG file at 300dpi in a user defined directory with stripped EXIF

       

      Thanks.

       

      Regards,

      Andy

        • 1. Re: How to strip EXIF data by scripting?
          Paul Riggott Level 6

          It should be possible to do this in Bridge by creating a new JPG via bitmap and copy the schemas omiting the camera details to the new jpgs

          • 2. Re: How to strip EXIF data by scripting?
            Paul Riggott Level 6

            As an example...

             

             

            #target bridge
            app.bringToFront();
            var outputFolder = Folder(app.document.presentationPath + "/out");
            if(!outputFolder.exists) outputFolder.create();
            var sels =app.document.getSelection("jpg,psd,tif");
            for(var a in sels){
            var sourceFile = File(sels[a].spec);
            var Name = decodeURI(sourceFile.name).replace(/\.[^\.]+$/, '');
            var destFile = File(outputFolder +"/" + Name + ".jpg");
            var thumb = new Thumbnail(sourceFile);
            var bm = new BitmapData(thumb.spec);
            bm = bm.rotate(thumb.rotation); 
            bm.exportTo(destFile,80); 
            updateMetaData(sourceFile,destFile);
            }
            function updateMetaData(sourceFile,destFile){
            if (ExternalObject.AdobeXMPScript == undefined)  ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
            sourceFile = new Thumbnail(File(sourceFile));
            destFile = new Thumbnail(File(destFile));
            var md = sourceFile.synchronousMetadata;
            var source = new XMPMeta( md.serialize() );
            var md2 = destFile.synchronousMetadata;
            var dest = new XMPMeta( md2.serialize() );
            try{
            copySchema( source, dest,XMPConst.NS_DC,[]);
            copySchema( source, dest,XMPConst.NS_TIFF,["Make","Model"]);
            copySchema( source, dest,XMPConst.NS_XMP_RIGHTS,[]);
            copySchema( source, dest,XMPConst.NS_IPTC_CORE,[]);
            var updatedPacket = dest.serialize(XMPConst.SERIALIZE_OMIT_PACKET_WRAPPER | XMPConst.SERIALIZE_USE_COMPACT_FORMAT);
            destFile.metadata = new Metadata(updatedPacket);
            app.document.refresh();
            }catch(e){alert(e+" "+e.line);}
            }
            function copySchema( source, dest, namespace, omitProps ) {  
             var propIter = source.iterator(XMPConst.ITERATOR_JUST_CHILDREN | XMPConst.ITERATOR_JUST_LEAF_NAME, namespace, "" );
             var prop = propIter.next();
             var prefix = XMPMeta.getNamespacePrefix( namespace );
             while(prop) {      
              var name = prop.path.substring( prefix.length );     
               if(omitProps != undefined) var copy = !contains( omitProps, name);
              if( copy ) {
                        try{
               XMPUtils.duplicateSubtree( source, dest, namespace, prop.path,namespace, prop.path, 0 );        
                        }catch(e){}
              }
              prop = propIter.next();
             }         
            }
            function contains( arr, member ){
             var r = false;
             for( var i = 0; i < arr.length &! r; ++i  ) {
              r = arr[i] == member;
             }
             return r;
            } 
            
            
             
            • 3. Re: How to strip EXIF data by scripting?
              andyg543210 Level 1

              Thanks Paul,

               

              I'll go and try that approach.

               

              I never thought about trying it through Bridge.

              • 4. Re: How to strip EXIF data by scripting?
                SteveCamb

                Have you tried the StripExif script which is on Adobe Exchange?

                 

                http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&extid=1043755#

                 

                I've been using it within my workflow since CS2 without any problems.

                 

                Cheers

                 

                Steve

                • 5. Re: How to strip EXIF data by scripting?
                  Paul Riggott Level 6

                  I hope you have corrected the typo in that script?

                   

                  var m = originalDoc.Mod

                  should be :

                  var m = originalDoc.mode;

                  • 6. Re: How to strip EXIF data by scripting?
                    LordSiegfried

                    Does this 'StripExif' script require any additional changes to run correctly (after your above change) to execute Properly under CS5 (12.0.4) running on OSX 10.8.3 (mountain lion)

                     

                    With an image opend, I get the following popup error:

                     

                    Error 1246: Illegal argument - argument 5

                    - Wrong type of enumerated value

                    Line: 47

                    ->    var stripDoc = documents.add(x, y, r, Filename,m , DocumentFill.TRANSPARENT);

                     

                     

                    Sorry, I don't know enough about this scripting to understand Where this is going wrong???

                     

                        thanks;

                     

                            ---michael