Hello Guys

In some part of my coding i want to obtain the width and height of an image in terms of PIXELs
I tried the following

//the rest above aren't important
$path = $_SERVER[DOCUMENT_ROOT].'/images/'.$image;
           $imgdata = getimagesize($path); 
           $imgdata[0] = $width;
           $imgdata[1] = $height;
           If ($width > 800 || $height > 600) {
            //do some work here
           }

When i added the if statement , the code between curly braket don't get executed(no error shown though).However if i remove the if condition , my code get executed
I believe error is one of these
1.Some error in if statement - less probable
2.The getimagesize is wrong or don't return values in pixels(most likely)

I know someone will point out the error :)

Thanks in advance

Recommended Answers

All 2 Replies

Change this part:

$imgdata[0] = $width;
$imgdata[1] = $height;

with this:

$width = $imgdata[0];
$height = $imgdata[1];

bye!

commented: The awesome helper of all time~Khav +1

Perfect bro........How could i missed such an obvious mistake lol
Finally found how to Rep.........+1 from me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.