4 Replies Latest reply on May 31, 2011 1:47 AM by Paul Riggott

    Automation of PhotoShop Elements

    SerialtechDM

      I am trying to setup PhotoShop Elements (PSE) to resize some images and save them as bitmaps and have been referred to this forum for assistance.

       

      The code below works up to a point, it loads and resizes the image correctly, but when it comes to saving - the file name shown in the PSE dialog is not the one sent but the original with a BMP extension.

       

      Manually clicking on the PSE "Save" button throws an error  '"Could not save...because of a problem with the plug-in module interface"

       

      It must be a basic error I've made but I cannot see it at the moment.

       

      Has anyone managed to code this sequence of events with PSE.

       

      Thanks

       

       

      David

       

       

      // ##############################

       

          Control1:=APhotoshopApplication.MakeControlObject;


          Desc1:=APhotoshopApplication.MakeDescriptor;
          Desc2:=APhotoshopApplication.MakeDescriptor;
          // load original file
          Doc:=APhotoshopApplication.Open('C:\temp\asi crash1.jpg');
          // prepare to resize image
          desc1.clear;
          desc1.PutUnitDouble(phKeyWidth, phUnitPixels, 1920);
          desc1.PutBoolean(phKeyConstrainProportions, 1);
          desc1.PutEnumerated(phKeyInterfaceIconFrameDimmed,
              phTypeInterpolation,phEnumBicubic);
          // resize image
          res:=Control1.Play(phEventImageSize,Desc1,phDialogSilent);
          //
          // prepare to save image as bitmap
          desc2.clear;
          desc2.PutEnumerated(phKeyPlatform,phTypePlatform,phEnumWindows);
          desc2.PutEnumerated(phKeyBitDepth,phTypeBitDepth,phEnumBitDepth24);
          desc2.PutEnumerated(phKeyCompression,phTypeBoolean,0);
          //
          desc1.clear;
          desc1.PutObject(phKeyAs,phClassBMPFormat,desc2);
          desc1.PutPath(phKeyIn,'test');                                           // not sure about this line
          desc1.PutBoolean(phKeyCopy,0);
          desc1.PutBoolean(phKeyExtension, 0);
          desc1.PutBoolean(phKeyLowerCase, 1);
          desc1.PutBoolean(phKeyFlatten, 0);
          desc1.PutBoolean(phKeyAlphaChannels, 0);
          desc1.PutBoolean(phKeyNonImageData, 0);
          desc1.PutEnumerated(phKeyPreview,phTypePreview,phEnumPreviewOff);
          // save image as bitmap
          control1.Play(phEventSave,desc1,phDialogDisplay);
          //
          Doc.close;
        • 1. Re: Automation of PhotoShop Elements
          JJMack Most Valuable Participant

          Try posting this in the Photoshop Elements forum

          • 2. Re: Automation of PhotoShop Elements
            SerialtechDM Level 1

            Thanks, I did originally post the message in Photoshop Elements

            but the response there was to try the more specialist Photoshop Scripting forum as it is possibly a question common to both products.

            • 3. Re: Automation of PhotoShop Elements
              Paul Riggott Level 6

              I don't have elements and not many people use .NET

              In JavaScript it would be something on the lines of :-

               

              var startRulerUnits = preferences.rulerUnits;
              preferences.rulerUnits = Units.PIXELS;
              var file = new File("/c/temp/asi crash1.jpg");
              open(file);
              var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
              app.activeDocument.resizeImage(1920, undefined, undefined, ResampleMethod.BICUBICSHARPER);
              var saveFile = File(file.path +"/" +Name +".bmp");
              SaveBMP(saveFile);
              app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
              app.preferences.rulerUnits = startRulerUnits;
              function SaveBMP(savefile){
              saveBMP = new BMPSaveOptions(); 
              saveBMP.alphaChannels = false; 
              saveBMP.depth = BMPDepthType.TWENTYFOUR; 
              saveBMP.flipRowOrder = false; 
              saveBMP.rleCompression = false; 
              saveBMP.osType = OperatingSystem.WINDOWS; 
              activeDocument.saveAs(saveFile, saveBMP, true, Extension.LOWERCASE); 
              }
              
              • 4. Re: Automation of PhotoShop Elements
                xbytor2 Level 4

                Photoshop Elements does not officially support scripting, though it does support Actions as describe in the docs.

                 

                You can use the ScriptingListener plugin from PSCS with PSE. That may help you work through your problems.

                 

                Also, note that not all features in PSCS are not supported in PSE. And the current version of PSE is based on

                PSCS4.