Hello again,

I've been working on my photo gallery, and came across a problem with the display section. I have images that are 400x300 and images that are 300x400.

Is there any way to make a statement such that:

if IMAGE DIMENSIONS = 300x400
then MY CODE HERE
else MY OTHER CODE HERE

Is this even possible, or is this not a feature available in PHP yet?

Thanks,

~ Reality15
Owner of MIRollerCoast.com

    you can use

    $fileSize = getimagesize("filename.jpg");

    which will return a value similar to

    width="625" height="233"

    so i would say, if you are using exact sizes, then yes, get your variable like this, then do the following

    if($fileSize[3] == "width=\"300\" height=\"400\") {
        do this
      } else { 
        do that 
    }

    edit: corrected syntax,(thanks bradgrafelmanfor pointing it out) will return the values i supplied, tested and works now

      Other than the erraneous syntax in kender's post, that method of checking getimagesize()'s returned values is incorrect. It returns an array, so you would more likely be doing:

      list($width, $height) = getimagesize('image.jpg');
      
      if($width == 300 && $height == 400) {

      as posted in the manual page for [man]getimagesize/man.

        Thanks! I'm assuming this works for all image types?

          GIF, JPG, PNG, SWF, SWC, PSD, TIFF, BMP, IFF, JP2, JPX, JB2, JPC, XBM, or WBMP

            Write a Reply...