6 Replies Latest reply on Mar 20, 2011 9:50 AM by sasientry

    Canvas size problem help me 3/4 canvas

    sasientry Level 1

      i have a problem when crop images in white background my images also deleted

      so i want canvas images when have width 3 ratio height 4 ratio

       

       

      i want images canvas this size height must 4000 px width must 3000 px

      i want images canvas this size height must 3000 px width must 2250 px

      i want images canvas this size height must 2500 px width must 1875 px

      i want images canvas this size height must 2000 px width must 1500 px

      i want images canvas this size height must 1100 px width must 825 px

        • 1. Re: Canvas size problem help me 3/4 canvas
          sasientry Level 1

          images when have height smaller than 1100, 1500, 2000, 2500, 3000, 4000 px
          images when have width smaller than 825, 1125, 1500, 1875, 2250, 3000 px

           

          i want images canvas this size height must 4000 px width must 3000 px

           

          i want images canvas this size height must 3000 px width must 2250 px

           

          i want images canvas this size height must 2500 px width must 1875 px

           

          i want images canvas this size height must 2000 px width must 1500 px

           

          i want images canvas this size height must 1500 px width must 1125 px

           

          i want images canvas this size height must 1100 px width must 825 px

          • 2. Re: Canvas size problem help me 3/4 canvas
            JJMack Most Valuable Participant

            It reads like English is not your native language while it is mine I failed every English course I took so we may have a hard time communicating.  Still I will try to have a go at it.

             

            If the image does not have a 3:4 aspect ratio you must either crop away some of you image pixels to make it have a 3:4 aspect ratio or you must size your image to fit within the 3:4 aspect ratio area you want and have white border on one side or two borders  on opposite side of equal size.   I think from what you wrote what you want is to not crop any pixels and size the image onto a 3:4 aspect ratio canvas you want.  You can do that with two steps in Photoshop.

             

            Step 1 menu File>Automate>Fit Image then in the Fit Image dialog enter one of your 3:4 aspect ratio like width 3000 and height 4000.

            The Fit Image plug-in will resize your image to fit within an area that size if you image does not have a 3:4 aspect ratio the image will be resized smaller then width 3000 and height 4000 however the images longest side will either be 3000 or 4000 pixel in other words portrait will be either be 4000 pixel high but less the 3000 or 3000 pixel wide  with a height greatrer then 3000 pixels but less then 4000 pixel high.   Landscape will be 3000 pixels wide  and less the 3000 pixels high.

             

            Step 2 menu Image>Canvas Size in the canvas size dialog leave the anchor point the center white square in the center if you want two borders or move it to one of the corner spots if you want a single border. Then enter the same sizes you used in the Fit Image dialog

            • 3. Re: Canvas size problem help me 3/4 canvas
              sasientry Level 1

              I want this for script because i have lot of images like shirts

               

              First make background to white after i trim that images to make tight and fit

               

              After i want script for 3/4 ratio canvas size

               

              pls help me

              • 4. Re: Canvas size problem help me 3/4 canvas
                sasientry Level 1

                When i run this script i my shirt image was croped

                 

                but i loss shirt image little bit in hands so i dont want crop in square image just i want canvas height  in 3/4 ratio

                 

                if (app.documents.length > 0) {

                 

                var docRef = app.activeDocument;
                var WidthRatio = 3;
                var HeightRatio = 4;
                var boundTop;
                var boundLeft;
                var boundRight;
                var boundBottom;

                 

                // Image's aspect ratio is greater than the desired ratio
                // so crop out left and right areas of the Image
                if ((docRef.width / docRef.height) > (WidthRatio/ HeightRatio))
                {
                boundTop = 0;
                boundLeft = ((docRef.width - (docRef.height * (WidthRatio/HeightRatio))) / 2);
                boundBottom = docRef.height;
                boundRight = ((docRef.width + (docRef.height * (WidthRatio/HeightRatio))) / 2);
                bounds = new Array(boundLeft,boundTop,boundRight,boundBottom);
                docRef.crop(bounds);
                }

                 

                // Image's aspect ratio is less than the desired ratio
                // so crop out top and bottom areas of the Image
                if ((docRef.width / docRef.height) < (WidthRatio/ HeightRatio))
                {
                boundTop = ((docRef.height - (docRef.width * (HeightRatio/WidthRatio))) / 2);
                boundLeft = 0;
                boundBottom = ((docRef.height + (docRef.width * (HeightRatio/WidthRatio))) / 2);
                boundRight = docRef.width;
                bounds = new Array(boundLeft,boundTop,boundRight,boundBottom);
                docRef.crop(bounds);
                }

                 

                // bounds = new Array(10, 10, app.activeDocument.width - 10, app.activeDocument.height - 10);
                // docRef.crop(bounds);

                 

                boundTop = null;
                boundLeft = null;
                boundRight = null;
                boundBottom = null;
                WidthRatio = null;
                HeightRatio = null;
                docRef = null;

                 

                }

                • 5. Re: Canvas size problem help me 3/4 canvas
                  JJMack Most Valuable Participant

                  You have to do the fit image thing and then add canvas to make the canvas have a 3:4 aspect ratio.  The Fit Image Plug-in that ships with Photoshop is a Script in Photoshop Presets/scripts folder.  You can get the logic out of it to do the fit part.  The problem is you started the other thread

                   

                   

                  when i have above 3000 pixels image must resize 3000

                  when i have pixels between 2999 px to 2501 px i want to resize 2500 px

                  when i have pixels between 2499 px to 2001 px i want to resize 2000 px
                  when i have pixels between 1999 px to 1501 px i want to resize 1500 px

                  when i have pixels between 1499 px to 1101 px i want to resize 1000 px

                  don't change image when have 3000,2500,2000,1500,1100 pixels

                   

                  This does not take into account an image orintation Portrait or Landscape and their aspect ratios. This thread your writting about Portrait Canvas with a Aspect ratio of 3:4  You must fit your images into this 3:4 Portrait Aspect Ratio Area. Your images will fall into  Four groups.  One its a portrait image with a 3:4 Aspect ratio. Two it a portrait with an aspect ratio that is wider then 3:4. Three its a Portrait Narower then 3:4. Four the image is a Landscape width is larger then height.  When these get fitted to 3:4 Aspect Ratio. The ones in the First group are perfect no bordere. Two will have small borders on top and bottom.  Three will have small borders on both sides.  Four will have large borders on top and bottom.

                   

                   

                  c.pfaffenbichler

                  Script in the other thread should work if all your images have a portrait orintation for it first changes your non 3:4 aspect ratio portrait  images to have a 3:4 aspect Ratio by adding canvas then changes the Image size based on the image height given the sizes you wrote about is height.  This script may fail if an image has a landscape orintation my brain is telling me but it has been known to make errors. It may work could just be the cobwebs in my brain not letting me see the answer.

                  • 6. Re: Canvas size problem help me 3/4 canvas
                    sasientry Level 1

                    Hi JJMack

                     

                    i got this answer its helpfull to me

                     

                    thanks for helping me?

                    // 2011, use it at your own risk;
                    #target photoshop
                    // set to pixels;
                    var originalRulerUnits = app.preferences.rulerUnits;
                    app.preferences.rulerUnits = Units.PIXELS;
                    // define file;
                    var myDocument = app.activeDocument;
                    var width = myDocument.width;
                    var height = myDocument.height;
                    var resolution = myDocument.resolution;
                    var theRatio = width/height;
                    resetForeAndBackgroud ();
                    // change canvas to fit the ratio of 3/4;
                    if (width/height > 3/4) {
                    myDocument.resizeCanvas(width, width * 4 / 3)
                    };
                    if (width/height < 3/4) {
                    myDocument.resizeCanvas(height * 3 / 4, height)
                    };
                    // do the resizing;
                    if (height < 2500 && height > 2000) {
                    var theScale = new UnitValue (2000 / height * 100, "%");
                    myDocument.resizeImage(theScale, theScale, resolution, ResampleMethod.BICUBIC)
                    };
                    if (height < 3000 && height > 2500) {
                    var theScale = new UnitValue (2500 / height * 100, "%");
                    myDocument.resizeImage(theScale, theScale, resolution, ResampleMethod.BICUBIC)
                    };
                    if (height > 3000) {
                    var theScale = new UnitValue (3000 / height * 100, "%");
                    myDocument.resizeImage(theScale, theScale, resolution, ResampleMethod.BICUBIC)
                    };
                    //reset;
                    app.preferences.rulerUnits = originalRulerUnits;
                    ////// reset fore- and background color //////
                    function resetForeAndBackgroud () {
                    // =======================================================
                    var idRset = charIDToTypeID( "Rset" );
                    var desc2 = new ActionDescriptor();
                    var idnull = charIDToTypeID( "null" );
                    var ref1 = new ActionReference();
                    var idClr = charIDToTypeID( "Clr " );
                    var idClrs = charIDToTypeID( "Clrs" );
                    ref1.putProperty( idClr, idClrs );
                    desc2.putReference( idnull, ref1 );
                    executeAction( idRset, desc2, DialogModes.NO );
                    };