4 Replies Latest reply on Aug 25, 2011 5:07 AM by c.pfaffenbichler

    Resize image by file dimension

    Marco Lugli



      is it possible to resize an image by its file size with Extendscript?


      For example:


      my original image is a .psd file with this dimension: 11.985.384 bytes


      I want to scale it down to, let's say, this dimension: 5.000.000 bytes


      Is this possible?


      I use Photoshop CS3, but I think the sintax may be the same also for CS5


      Any suggestions would be much appreciated


      Thanks in advance

        • 1. Re: Resize image by file dimension
          JJMack Most Valuable Participant

          How large a file is depens on many factors.  File type and the settings used creating files plays a very big part.  However the major size component on any image file type format is always the recording of the images pixels.


          Just look at saving a Jpeg file whithout changing the image size you can save jpeg files that have 13 sizes just using the quality setting.

          For example for this raw file IMG_2771.CR2   7,541,502 with these ACR setting IMG_2771.xmp   7,281 saving jpeg file using settinge 0 through 12  produces these file sizes range under 200KB to over 3.5MB


          IMG_2771-0.jpg            191,459

          IMG_2771-1.jpg            211,425

          IMG_2771-2.jpg            259,895

          IMG_2771-3.jpg            315,356

          IMG_2771-4.jpg            352,926

          IMG_2771-5.jpg            408,041

          IMG_2771-6.jpg            513,341

          IMG_2771-7.jpg            553,543

          IMG_2771-8.jpg            710,712

          IMG_2771-9.jpg            900,429

          IMG_2771-10.jpg         1,242,657

          IMG_2771-11.jpg         2,009,077

          IMG_2771-12.jpg         3,563,352

          • 2. Re: Resize image by file dimension
            Marco Lugli Level 1

            So, do you think it is not possible to "force" the final dimension of a file? Doesn't exist any sintax in Extendscript that refers to the bytes or something similar?

            • 3. Re: Resize image by file dimension
              JJMack Most Valuable Participant

              Repeat How large a file is depens on many factors. You have not even specified a file type. Only an uncompressed file format would have a predictable file size.


              Look at it this way  the bigest part on any image file is the recording of its pixels.  Most file formats will use data compressing in the process recording pixel data.  You can not predict the size data will compress to for it depend on the data content.  Think of data content as image content.  How much detail is there is the image very buzzy like a crossword puzzle or does it have huge consistant areas like blue sky.   If you look at your camera files captured af full resolition the all have the same number of pixels. Look at their file sizes RAW and JPEG  do all image have the same file size after all the all have the same number of pixels and meta data. Do any nave the same file size sort them by size.

              • 4. Re: Resize image by file dimension
                c.pfaffenbichler Level 9

                »dimensions« usually refers to the horizontal and vertical measurements, not the file’s size in bytes.

                And you still have not even mentioned the file format …


                A poster in this thread seems to have found a Script that helped him with regard to file-size (Edit:) for Save for Web & Devices: