1 Reply Latest reply on Apr 11, 2007 4:02 AM by Newsgroup_User

    How to read in JPEG file properties

    ropeGun Level 1
      Hello AS Community!

      I am wondering if there is some way to do the following:

      (1) I have a folder filled with JPEGS with which I can have my SWF access via XML.
      (2) I would like to create two arrays, one filled with the widths (in pixels) and the other with heights (in pixels) of all of these JPEGs in the aforementioned folder.

      I am not interested in loading/viewing any of the JPEGs from this folder into my SWF, I really just want the SWF to use each image's width/height information for something else.

      Do you know how when you right-click in Windows and choose "Properties" of a JPEG image, you can see the width/height values of said JPEG in pixels? It is these properties that I would like to load into arrays. I know how to create and load up arrays, so that is not the topic of this post, but rather how do I read in these Windows "intrinsic" width/height properties?

      Any help would be greatly appreciated,

      -john
        • 1. Re: How to read in JPEG file properties
          Level 7
          ropeGun wrote:
          > Hello AS Community!
          >
          > I am wondering if there is some way to do the following:
          >
          > (1) I have a folder filled with JPEGS with which I can have my SWF access via
          > XML.
          > (2) I would like to create two arrays, one filled with the widths (in pixels)
          > and the other with heights (in pixels) of all of these JPEGs in the
          > aforementioned folder.
          >
          > I am not interested in loading/viewing any of the JPEGs from this folder into
          > my SWF, I really just want the SWF to use each image's width/height information
          > for something else.
          >
          > Do you know how when you right-click in Windows and choose "Properties" of a
          > JPEG image, you can see the width/height values of said JPEG in pixels? It is
          > these properties that I would like to load into arrays. I know how to create
          > and load up arrays, so that is not the topic of this post, but rather how do I
          > read in these Windows "intrinsic" width/height properties?
          >
          > Any help would be greatly appreciated,
          >
          > -john
          >
          Hi ropeGun,

          You're only really going to achieve this with a server side script
          written in PHP, ASP etc. You can then get the script to loop through the
          folder and examine each file and store it's width and height. How you
          then pass this information back to Flash is down to your personal
          preference. You could go the 'name/value' pairs route, but with a large
          directory you run the risk of loading in a rather large amount of data
          in a less than ideal format.

          A more concise route would be to use some form of remoting like AMFPHP
          (www.amfphp.org) and just get the PHP to make the Arrays too and pass
          the complex data back all at once. This will save processing and
          mangling once it hits Flash.Leaving you with just hooking up the arrays.

          Obviously if you were loading them in then you could just grab these
          values once loaded, but this isn't your goal as you have already indicated.

          Might I suggest you use a multi-dimensional array to store these width
          and height values in. It will make accessing the values far easier and
          will make sure you only have to contend with one index per JPG
          dimensions. I suspect you were already planning on doing that anyhoo :D

          HTH

          --
          regs
          m

          ------------------------------------
          Mike Jones
          FlashGen.Com
          ------------------------------------
          w./ www.flashgen.com
          e./ forum_postsATflashgenDOTcom
          b./ blog.flashgen.com
          ------------------------------------