cmgmyr Posted March 27, 2006 Share Posted March 27, 2006 ok I have a little photo gallery on a site. I made up a little bit of code that resizes the image if it is too big.The script works fine when it's on my local computer, but when I upload it the script takes the image size of the image after the one it's supposed to, but outputs the image it is supposed to.If I have image1 and image2, When I try and get the size of image1 it takes the size of image2, but still outputs image1...I don't get it...here is my code, please help if you can![code] if (!isset($userid) or trim($userid)=='') { $gal = 1; } if (!isset($pic) or trim($pic)=='') { $pic = 1; } $dir= "custphotos/gallery".$userid; @$d = dir($dir); if ($d) { while($entry=$d->read()) { $entry = preg_replace("/ /","%20",$entry); $pos = strpos (strtolower($entry), ".jpg"); if (!($pos === false)) { $arr_pic[] = $dir."/".$entry; } } $d->close(); } $CONST_WIDTH = 250; //Find image h and w $size = getimagesize($arr_pic[$pic-1]); $w = $size[0]; $h = $size[1]; if($w > $CONST_WIDTH){ //Find % $percent = $w / $CONST_WIDTH; $w = $w / $percent; $h = $h / $percent; } @sort ($arr_pic); $total = sizeof($arr_pic); echo "<div align=\"center\"><img width=\"$w\" height=\"$h\" src=".$arr_pic[$pic-1]."><br>";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/5900-image-problems/ Share on other sites More sharing options...
redarrow Posted March 27, 2006 Share Posted March 27, 2006 a guess$w = $size[0];$h = $size[1];This[code]$w = $size[0];$h = $size[0];[/code]or[code]$w = $size[1];$h = $size[1];[/code]good luck only learning my self please always back you files up. Quote Link to comment https://forums.phpfreaks.com/topic/5900-image-problems/#findComment-21063 Share on other sites More sharing options...
cmgmyr Posted March 27, 2006 Author Share Posted March 27, 2006 Nope, still didn't work. Any other ideas out there??? Quote Link to comment https://forums.phpfreaks.com/topic/5900-image-problems/#findComment-21331 Share on other sites More sharing options...
Barand Posted March 28, 2006 Share Posted March 28, 2006 Could be that the array sort is screwing up the array indexes. Quote Link to comment https://forums.phpfreaks.com/topic/5900-image-problems/#findComment-21541 Share on other sites More sharing options...
cmgmyr Posted March 28, 2006 Author Share Posted March 28, 2006 So what do I have to do to fix it? Quote Link to comment https://forums.phpfreaks.com/topic/5900-image-problems/#findComment-21585 Share on other sites More sharing options...
ober Posted March 28, 2006 Share Posted March 28, 2006 What are the PHP versions on both your local machine and the host? Quote Link to comment https://forums.phpfreaks.com/topic/5900-image-problems/#findComment-21588 Share on other sites More sharing options...
cmgmyr Posted April 4, 2006 Author Share Posted April 4, 2006 Local: 4.4.0Server: 4.3.10Thanks,-Chris Quote Link to comment https://forums.phpfreaks.com/topic/5900-image-problems/#findComment-23958 Share on other sites More sharing options...
redbullmarky Posted April 4, 2006 Share Posted April 4, 2006 [!--quoteo(post=361711:date=Apr 4 2006, 09:21 PM:name=cmgmyr)--][div class=\'quotetop\']QUOTE(cmgmyr @ Apr 4 2006, 09:21 PM) [snapback]361711[/snapback][/div][div class=\'quotemain\'][!--quotec--]Local: 4.4.0Server: 4.3.10Thanks,-Chris[/quote]looking at your code and at the post by [b]Barand[/b], I think he's hit the nail on the head. Have you tried what he suggested? Lose the @sort line (for the purpose of testing) and see what happens. Quote Link to comment https://forums.phpfreaks.com/topic/5900-image-problems/#findComment-23977 Share on other sites More sharing options...
cmgmyr Posted April 5, 2006 Author Share Posted April 5, 2006 Ok...that fixed the size problem...but caused another.The customers are allowed 5 photos. I originally had it set up to where they can re-name the photos to change the order of them on their profile, but now it's not working like that. The way that it is set up now it shows the second picture [$pic-1] when I try [$pic-2] none of the images show up.Is there a way to get around this one?Thanks Quote Link to comment https://forums.phpfreaks.com/topic/5900-image-problems/#findComment-24053 Share on other sites More sharing options...
Barand Posted April 5, 2006 Share Posted April 5, 2006 try changing the second part of your code[code] $CONST_WIDTH = 250; @sort ($arr_pic); foreach ($arr_pic as $picfile) { //Find image h and w $size = getimagesize($picfile); $w = $size[0]; $h = $size[1]; if($w > $CONST_WIDTH){ //Find % $percent = $w / $CONST_WIDTH; $w = $w / $percent; $h = $h / $percent; } echo "<div align=\"center\"><img width=\"$w\" height=\"$h\" src=\"$picfile\"><br>"; }[/code] Quote Link to comment https://forums.phpfreaks.com/topic/5900-image-problems/#findComment-24126 Share on other sites More sharing options...
cmgmyr Posted April 5, 2006 Author Share Posted April 5, 2006 FIXED!I moved the sort more to the top:[code]@sort ($arr_pic);$CONST_WIDTH = 250;[/code]Thanks for all of your help! Quote Link to comment https://forums.phpfreaks.com/topic/5900-image-problems/#findComment-24170 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.