Forum Moderators: coopster
$imagehw = getimagesize($image[$r]);
$imagewidth = $imagehw[0];
$imageheight = $imagehw[1];
if ($imagewidth>$maxwidth) {
$imageprop = ($maxwidth*100)/$imagewidth;
$imagevsize = ($imageheight*$imageprop)/100;
$imagewidth = $maxwidth;
$imageheight = ceil($imagevsize);
Its one of those usual image resizing items for a random picture gallery. All the images are jpg, etc.
Here's the issue. On my test-bed server I'm running PHP 4.3.3 on a windows platform. Everything works as it should. Images change everytime the page refreshes, etc. On the hosted site - NOTHING. The host was previously running PHP 4.2.3. Apparently there was an issue with 4.2.3 in running getimagesize where height and width were zero sized.
The hosting company has just upgraded PHP to 4.3.4 and --- the issue remains the same. Put the gallery in place. On the status bar you can see the image coming through but, barring a dot on the screen, there's no image.
Other than doing a re-write, I'm not sure where else to look. I mean, the question begs: why is the code working in one situation and not the other?
#######
<?php
if ($s[picture]){
$size =getimagesize($s[picture]);
$width=$size[0];
$height=$size[1];
?>
<tr>
<td align=center>
<img src="<?php print $s[picture];?>">
width=<?php print $width;?> height=<?php print$height;?>
</td></tr>
<?php }?>
########
regards
HEnry
The format of images you are able to manipulate depend on the version of GD installed as well as any other libraries GD might need to access those image formats. You may want to make sure your host has the jpeg library installed. If they aren't sure, send them here [php.net] ;)
Guys, where I'm lost here is, why is this working in one environment and not the other?
Have just spent the last couple of hours trawling the net on this item. php.net has this,
Some formats may contain no image or multiple images. In such cases GetImageSize might not be able to determine the size and returns zero for width and height.
As far as can see, an a single image is coming down the pipe - as in watching the status bar. Doing a right-click view source both width and height = '' - as in empty. Have the same images loaded on each platform so I don't think that's the issue.
From another source, I found this:
getImageSize() is not working with remote files.
It always gives a warning with every image file.
Imagefiles were checked and were not corrupted.
Local files work just fine.
That just about typifies my situation except that there are no warning messages and there is an image - albeit a 1 pixel dot. BTW the above is a message in php's bugtrack.
Coopster, what I can't figure out is that the code above is not calling GD - even though both services are running 2.x - so this shouldn't or doesn't appear to come into the equation.
Henry, I'll take a look at your code and run it a little later. Time to call it a day here.
True. You actually aren't manipulating the image so you don't need GD. I didn't read your first post close enough, sorry.
>>getImageSize() is not working with remote files...
>>That just about typifies my situation except that there are
>>no warning messages and there is an image - albeit a 1 pixel
>>dot. BTW the above is a message in php's bugtrack.
I can't tell from your code here --
$imagehw = getimagesize($image[$r]);
$image[$r] is actually a remote file or not. The bugtrack message is referring to a remote file (url). If your variable is not referring to a url, then the bug may not apply. Have you tried different images yet? I'm wondering if the image is the issue? I tested your code on a PHP 4.3.2 installation I have and it works fine with both local images and remote images (I grabbed a jpg off a different site).
$r = rand(0,$count-1);
where
$count = sizeof($image_array);
okay, so after all my beefing have managed to resolve this issue. It wasn't in the code. Peddled the images through fireworks instead of PS - just in case. No issue there.
As a last resort checked out my error logs and - we have this:
web host ip address - - [05/Dec/2003:21:35:52 -0600] "GET /images/dir/IMG_2581.jpg HTTP/1.0" 403 - "-" "-"
internet access ip address - - [05/Dec/2003:21:35:54 -0600] "GET /images/dir/IMG_2581.jpg HTTP/1.0" 200 45799 "http://www.****.org/dir/page.php" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Q312461)"
So the image was getting 403'ed. No notice my end though. Can see the image download and there's a spec on the screen.
In my .htaccess file I've banned linking as well as blank refers and UA's. Removed the code handling these matters and I have fireworks.
So this number's sorted out. It's now back to the drawing board on the htaccess thing.
Thanks guys.
BTW, Henry the code I provided here auto-scales images of any size down to a specific size - in this case width - while maintain the same aspect ratio (width to height). If the images are smaller, well, they stay that size.
In using getimagesize() it looks like the host first needs to "Get" the image to do the "resize" thing before delivering it to the browser and therein lies the problem. To do this, no refer details or UA's are used in performing the task. htaccess checks this out and does a 403 and no image. Remming out this feature in htaccess and the app works as designed. What a drag ...