13 Replies Latest reply on Feb 24, 2011 9:36 PM by SunilRana_Gateway

    as  increase DPI, image size is also  increase in photoshop scripting ?

    SunilRana_Gateway Level 1

      as  increase DPI, image size is also  increase in photoshop scripting can please tell me what  will the reason for that?

        • 1. Re: as  increase DPI, image size is also  increase in photoshop scripting ?
          Muppet Mark-QAl63s Level 4

          You need to supply a resample method of 'none' with your resize command… What language are you using? Something like…

           

          app.activeDocument.resizeImage(undefined, undefined, 600, ResampleMethod.NONE);
          

           

          If you were using ESTK.

          • 2. Re: as  increase DPI, image size is also  increase in photoshop scripting ?
            JJMack Most Valuable Participant

            You can also change an images DPI setting without changing the number of pixels in an image the only thing that changes is to image print size because the image prints at a different pixel density.

            • 3. Re: as  increase DPI, image size is also  increase in photoshop scripting ?
              SunilRana_Gateway Level 1

              Hi M Mark,

               

                                I am using adobe  Flex with  Photoshop scripting . I am sending  Flex file  with parameter to generate .psd.Right now i am able to generate 72 DPI with proper image size while  I am generating  .psd with  250 DPI with Improper Size.

               

              E.g

              This is my  flex parameters

              MgrPSAction.instance.FinishLayoutToPhotoshop(curFl , savedType ,TemplateConstant.TM_LEFT,getPSDImageName(objItem,TemplateConstant.TM_LEFT_RIGHT), objItem.LayoutTMLWidth,objItem.LayoutTMLHeight ,pageDPI,returnPhotoshopHandler,

               

              true,setWidth , setHeight,formatQty); ----- Page DPI - > like 72 or 250 paasing  from here.

               

               

              below is Scirpt ot resize

               

              function openFileAndResize(xp,yp,wi,hi,imagepath)

              {

              var fileRef = new File(imagepath);

              var curRefDoc = app.open(fileRef);

              var curw = curRefDoc.width;

              var curh = curRefDoc.height;

               

              var resW;

              var resH;

               

              var scw = imgObj.wi/curw;

              var sch = imgObj.hi/curh;

               

              var scale ;

              if(scw > sch)

              scale = scw;

              else

              scale = sch;

               

              resW = curw * scale;

              resH = curh * scale;

               

              if(imgObj.isAdjustImage == "true")

              {

              resW = resW * parseFloat (imgObj.scaleOrg);

              resH = resH * parseFloat (imgObj.scaleOrg);

              }

               

              // Resize Image=======================================================

              var idImgS = charIDToTypeID( "ImgS" );

              var desc226 = new ActionDescriptor();

              var idWdth = charIDToTypeID( "Wdth" );

              var idPxl = charIDToTypeID( "#Pxl" );

              desc226.putUnitDouble( idWdth, idPxl, resW);

              var idHght = charIDToTypeID( "Hght" );

              var idPxl = charIDToTypeID( "#Pxl" );

              desc226.putUnitDouble( idHght, idPxl, resH );

              var idIntr = charIDToTypeID( "Intr" );

              var idIntp = charIDToTypeID( "Intp" );

              var idBcbc = charIDToTypeID( "Bcbc" );

              desc226.putEnumerated( idIntr, idIntp, idBcbc );

              executeAction( idImgS, desc226, DialogModes.NO );

              // Select Image=======================================================

              var idsetd = charIDToTypeID( "setd" );

              var desc263 = new ActionDescriptor();

              var idnull = charIDToTypeID( "null" );

              var ref138 = new ActionReference();

              var idChnl = charIDToTypeID( "Chnl" );

              var idfsel = charIDToTypeID( "fsel" );

              ref138.putProperty( idChnl, idfsel );

              desc263.putReference( idnull, ref138 );

              var idT = charIDToTypeID( "T " );

              var idOrdn = charIDToTypeID( "Ordn" );

              var idAl = charIDToTypeID( "Al " );

              desc263.putEnumerated( idT, idOrdn, idAl );

              executeAction( idsetd, desc263, DialogModes.NO );

              //Copy Image=======================================================

              var idcopy = charIDToTypeID( "copy" );

              executeAction( idcopy, undefined, DialogModes.NO );

              app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

               

              //Create Temp Layer for image adjustment =======================================================

              //createApplication(wi,hi,dpi,"imagelayerdoc");

              createApplication(wi,hi,dpi,layerAppName);

              //var curDoc = getCurDoc('imagelayerdoc');

              //get Active Temp Layer for image adjustment =======================================================

              var curDoc = getCurDoc(layerAppName);

              app.activeDocument = curDoc;

               

              // Past Copy image in Temp Layer for image adjustment =======================================================

              var idpast = charIDToTypeID( "past" );

              var desc250 = new ActionDescriptor();

              var idAntA = charIDToTypeID( "AntA" );

              var idAnnt = charIDToTypeID( "Annt" );

              var idAnno = charIDToTypeID( "Anno" );

              desc250.putEnumerated( idAntA, idAnnt, idAnno );

              executeAction( idpast, desc250, DialogModes.NO );

               

              // HERE YOU NEED TO SET XY POSTION OF IMAGE

              positionLayer(app.activeDocument.activeLayer,imgObj.moveX,imgObj.moveY);

              cropImage();

              }

               

               

              Please reply if have answer...

              Thanks

              • 4. Re: as  increase DPI, image size is also  increase in photoshop scripting ?
                SunilRana_Gateway Level 1

                Hi JJMACK,

                 

                                  I am using adobe  Flex with  Photoshop scripting . I am sending  Flex file  with parameter to generate .psd.Right now i am able to generate 72 DPI with proper image size while  I am generating  .psd with  250 DPI with Improper Size.

                 

                E.g

                This is my  flex parameters

                MgrPSAction.instance.FinishLayoutToPhotoshop(curFl , savedType ,TemplateConstant.TM_LEFT,getPSDImageName(objItem,TemplateConstant.TM_LEFT_RIGHT), objItem.LayoutTMLWidth,objItem.LayoutTMLHeight ,pageDPI,returnPhotoshopHandler,

                 

                 

                true,setWidth , setHeight,formatQty); ----- Page DPI - > like 72 or 250 paasing  from here.

                 

                 

                below is Scirpt ot resize

                 

                function openFileAndResize(xp,yp,wi,hi,imagepath)

                {

                var fileRef = new File(imagepath);

                var curRefDoc = app.open(fileRef);

                var curw = curRefDoc.width;

                var curh = curRefDoc.height;

                 

                var resW;

                var resH;

                 

                var scw = imgObj.wi/curw;

                var sch = imgObj.hi/curh;

                 

                var scale ;

                if(scw > sch)

                scale = scw;

                else

                scale = sch;

                 

                resW = curw * scale;

                resH = curh * scale;

                 

                if(imgObj.isAdjustImage == "true")

                {

                resW = resW * parseFloat (imgObj.scaleOrg);

                resH = resH * parseFloat (imgObj.scaleOrg);

                }

                 

                // Resize Image=======================================================

                var idImgS = charIDToTypeID( "ImgS" );

                var desc226 = new ActionDescriptor();

                var idWdth = charIDToTypeID( "Wdth" );

                var idPxl = charIDToTypeID( "#Pxl" );

                desc226.putUnitDouble( idWdth, idPxl, resW);

                var idHght = charIDToTypeID( "Hght" );

                var idPxl = charIDToTypeID( "#Pxl" );

                desc226.putUnitDouble( idHght, idPxl, resH );

                var idIntr = charIDToTypeID( "Intr" );

                var idIntp = charIDToTypeID( "Intp" );

                var idBcbc = charIDToTypeID( "Bcbc" );

                desc226.putEnumerated( idIntr, idIntp, idBcbc );

                executeAction( idImgS, desc226, DialogModes.NO );

                // Select Image=======================================================

                var idsetd = charIDToTypeID( "setd" );

                var desc263 = new ActionDescriptor();

                var idnull = charIDToTypeID( "null" );

                var ref138 = new ActionReference();

                var idChnl = charIDToTypeID( "Chnl" );

                var idfsel = charIDToTypeID( "fsel" );

                ref138.putProperty( idChnl, idfsel );

                desc263.putReference( idnull, ref138 );

                var idT = charIDToTypeID( "T " );

                var idOrdn = charIDToTypeID( "Ordn" );

                var idAl = charIDToTypeID( "Al " );

                desc263.putEnumerated( idT, idOrdn, idAl );

                executeAction( idsetd, desc263, DialogModes.NO );

                //Copy Image=======================================================

                var idcopy = charIDToTypeID( "copy" );

                executeAction( idcopy, undefined, DialogModes.NO );

                app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

                 

                //Create Temp Layer for image adjustment =======================================================

                //createApplication(wi,hi,dpi,"imagelayerdoc");

                createApplication(wi,hi,dpi,layerAppName);

                //var curDoc = getCurDoc('imagelayerdoc');

                //get Active Temp Layer for image adjustment =======================================================

                var curDoc = getCurDoc(layerAppName);

                app.activeDocument = curDoc;

                 

                // Past Copy image in Temp Layer for image adjustment =======================================================

                var idpast = charIDToTypeID( "past" );

                var desc250 = new ActionDescriptor();

                var idAntA = charIDToTypeID( "AntA" );

                var idAnnt = charIDToTypeID( "Annt" );

                var idAnno = charIDToTypeID( "Anno" );

                desc250.putEnumerated( idAntA, idAnnt, idAnno );

                executeAction( idpast, desc250, DialogModes.NO );

                 

                // HERE YOU NEED TO SET XY POSTION OF IMAGE

                positionLayer(app.activeDocument.activeLayer,imgObj.moveX,imgObj.moveY);

                cropImage();

                }

                 

                 

                 

                Please reply if have answer...

                Thanks

                 

                • 5. Re: as  increase DPI, image size is also  increase in photoshop scripting ?
                  Michael L Hale Level 5

                  SunilRana_Gateway, do you fully understand your code?

                   

                  As Mark said you are resizing using the bicubic resample method. You need to change the resample method to none if you don't want to change the file size.

                   

                  I would suggest that you replace the action manager(scriptlistener) image size code you have now with Marks DOM version.

                  • 6. Re: as  increase DPI, image size is also  increase in photoshop scripting ?
                    Muppet Mark-QAl63s Level 4

                    Mike, flex What is this? I see a forum at your site… but what it do? Im guessing at some funky dialogs/panels front end UI stuff?

                    • 7. Re: as  increase DPI, image size is also  increase in photoshop scripting ?
                      Michael L Hale Level 5

                      Flex Builder or Flash Builder as it is called now can be used to create custom panels for Photoshop and other Adobe apps. The main advantage of custom panels over ScriptUI is the panels are non-modal. The main disadvantage is it is CS4/CS5 only.

                      • 8. Re: as  increase DPI, image size is also  increase in photoshop scripting ?
                        SunilRana_Gateway Level 1

                        Hi Michael,,

                         

                          Thanks but I need to 250DPI image with exact image size. so i must have resemple it .is it true?. please provide exact way to 250 DPI  image with exact sieze. right now my image size increase image size.

                         

                        Please explian  ::

                        I would suggest that you replace the action manager(scriptlistener) image size code you have now with Marks DOM version  and

                        resizing using the bicubic resample method

                         

                        or give  me link to study photshop scritpting .. i am new one in this.i am working in exsting code of my collegue who left the company. please help me out.

                         

                         

                        Thanks

                        Michael.

                        • 9. Re: as  increase DPI, image size is also  increase in photoshop scripting ?
                          Michael L Hale Level 5

                          I misunderstood your question. I thought you were asking why changing the ppi changed the image size. To keep the size and change the ppi you don't resample.

                           

                          When you resample an image the number of pixels changes and that effect the image size. It may increase or decrease depending on the values used.

                           

                          When you say 'exact image size' do you mean size in pixels or in some other unit such as cm? Even in cm an increase in ppi will result in a increase in image size.

                           

                          The JavaScript Ref.pdf that ships with Photoshop is a good start for learning to script Photoshop with javascript.

                          • 10. Re: as  increase DPI, image size is also  increase in photoshop scripting ?
                            SunilRana_Gateway Level 1

                            Hi Michael,

                             

                                IF i remove resempling then Image quality will reduce. I  want 300 DPI  image without increase size of image.please give good solutions for that.

                             

                            Thanks

                            Sunil

                            • 11. Re: as  increase DPI, image size is also  increase in photoshop scripting ?
                              Paul Riggott Level 6

                              As both Mark and Mike have said..

                              app.activeDocument.resizeImage(undefined, undefined, 300, ResampleMethod.NONE);

                              This will just change the PPI to 300 and nothing else.

                              • 12. Re: as  increase DPI, image size is also  increase in photoshop scripting ?
                                Michael L Hale Level 5

                                I think there must be a misunderstanding over what 'image size' means. I understand image size to mean the size of the image in mb or pixel dimenstions. Print size is the size in cm, in, etc at the current ppi. Changing the ppi only effects the print size when ResampleMethod.NONE is used.

                                 

                                Say I have an A6 72ppi document open and the ruler is set to cm.

                                 

                                app.activeDocument.resizeImage(undefined, undefined, 300, ResampleMethod.NONE);// sizeMB:same, sizePixel:same, sizeCM:changed

                                 

                                app.activeDocument.resizeImage(10.5, 14.5, 300, ResampleMethod.BICUBIC);// sizeMB:changed, sizePixel:changed, sizeCM:same

                                 

                                So ResampleMethod.NONE does not change the file size( mb or pixel dim ) but does change the print size. Other resampleMethods do change the file size and may change the print size.

                                 

                                There is no way to resample and keep both the file size(mb,px) and the print size(cm) the same. One or the other must change to resample.

                                • 13. Re: as  increase DPI, image size is also  increase in photoshop scripting ?
                                  SunilRana_Gateway Level 1

                                  Hi All,

                                   

                                   

                                  while Resizing Image ,added below code to get actuall size for generate psd

                                   

                                   

                                  var idImgS2 = charIDToTypeID( "ImgS" );

                                  var descResize2 = new ActionDescriptor();

                                  var idRW = charIDToTypeID( "Wdth" );

                                  var idRPx = charIDToTypeID( "#Pxl" );

                                  descResize2.putUnitDouble( idRW, idRPx, wi);

                                  var idRH = charIDToTypeID( "Hght" );

                                  idRPx = charIDToTypeID( "#Pxl" );

                                  descResize2.putUnitDouble( idRH, idPxl, hi);

                                  var idIntr = charIDToTypeID( "Intr" );

                                  var idIntp = charIDToTypeID( "Intp" );

                                  var idBcbc = charIDToTypeID( "Bcbc" );

                                  descResize2.putEnumerated( idIntr, idIntp, idBcbc );

                                  executeAction( idImgS2, descResize2, DialogModes.NO );

                                   

                                   

                                   

                                  Thank for All your support...

                                   

                                  Thanks

                                  Sunil Rana