cmgmyr Posted April 7, 2007 Share Posted April 7, 2007 Hey Guys, This is my script that I use for image resizing. I have a client on php5 and now i'm just getting those little red x's. He does have GD library and it is running. What do I need to change in order for it to work? <?php header("Content-type: image/jpeg"); $source = imagecreatefromjpeg($src); $orig_w=imagesx($source); $orig_h=imagesy($source); //See if there is a different height and width if(!$_GET['wmax']){ $wmax=100; } if(!$_GET['hmax']){ $hmax=100; } $quality=90; $bgcol=000000; if ($orig_w>$wmax || $orig_h>$hmax) { $thumb_w=$wmax; $thumb_h=$hmax; if ($thumb_w/$orig_w*$orig_h>$thumb_h) $thumb_w=round($thumb_h*$orig_w/$orig_h); else $thumb_h=round($thumb_w*$orig_h/$orig_w); } else { $thumb_w=$orig_w; $thumb_h=$orig_h; } if (!@$bgcol) { $thumb=imagecreatetruecolor($thumb_w,$thumb_h); imagecopyresampled($thumb,$source, 0,0,0,0,$thumb_w,$thumb_h,$orig_w,$orig_h); } else { $thumb=imagecreatetruecolor($wmax,$hmax); imagefilledrectangle($thumb,0,0,$wmax-1,$hmax-1,intval($bgcol,16)); imagecopyresampled($thumb,$source, round(($wmax-$thumb_w)/2),round(($hmax-$thumb_h)/2), 0,0,$thumb_w,$thumb_h,$orig_w,$orig_h); } if (!@$quality) $quality=90; imagejpeg($thumb,"",$quality); imagedestroy($thumb); ?> Thanks, -Chris Quote Link to comment https://forums.phpfreaks.com/topic/46014-solved-image-resizing-not-working/ Share on other sites More sharing options...
MadTechie Posted April 7, 2007 Share Posted April 7, 2007 i assume you are setting $src somewhere! Quote Link to comment https://forums.phpfreaks.com/topic/46014-solved-image-resizing-not-working/#findComment-223584 Share on other sites More sharing options...
MadTechie Posted April 7, 2007 Share Posted April 7, 2007 Works fine! test.php?scr=test.jpg <?php header("Content-type: image/jpeg"); $source = imagecreatefromjpeg($_GET['scr']); //<--updated $orig_w=imagesx($source); $orig_h=imagesy($source); //See if there is a different height and width if(!$_GET['wmax']){ $wmax=100; } if(!$_GET['hmax']){ $hmax=100; } $quality=90; $bgcol=000000; if ($orig_w>$wmax || $orig_h>$hmax) { $thumb_w=$wmax; $thumb_h=$hmax; if ($thumb_w/$orig_w*$orig_h>$thumb_h) $thumb_w=round($thumb_h*$orig_w/$orig_h); else $thumb_h=round($thumb_w*$orig_h/$orig_w); } else { $thumb_w=$orig_w; $thumb_h=$orig_h; } if (!@$bgcol) { $thumb=imagecreatetruecolor($thumb_w,$thumb_h); imagecopyresampled($thumb,$source, 0,0,0,0,$thumb_w,$thumb_h,$orig_w,$orig_h); } else { $thumb=imagecreatetruecolor($wmax,$hmax); imagefilledrectangle($thumb,0,0,$wmax-1,$hmax-1,intval($bgcol,16)); imagecopyresampled($thumb,$source, round(($wmax-$thumb_w)/2),round(($hmax-$thumb_h)/2), 0,0,$thumb_w,$thumb_h,$orig_w,$orig_h); } if (!@$quality) $quality=90; imagejpeg($thumb,"",$quality); imagedestroy($thumb); ?> NOTE THE CHANGE $source = imagecreatefromjpeg($_GET['scr']); Quote Link to comment https://forums.phpfreaks.com/topic/46014-solved-image-resizing-not-working/#findComment-223585 Share on other sites More sharing options...
cmgmyr Posted April 7, 2007 Author Share Posted April 7, 2007 ...yes It's something like this: <img src="thumb.php?src=images/cms_images/<?php echo $image ?>" /> The script works in php4 and not php5 Quote Link to comment https://forums.phpfreaks.com/topic/46014-solved-image-resizing-not-working/#findComment-223587 Share on other sites More sharing options...
MadTechie Posted April 7, 2007 Share Posted April 7, 2007 i run it on PHP Version 5.2.1, seams OK GD Version bundled (2.0.28 compatible) Quote Link to comment https://forums.phpfreaks.com/topic/46014-solved-image-resizing-not-working/#findComment-223588 Share on other sites More sharing options...
MadTechie Posted April 7, 2007 Share Posted April 7, 2007 as a note in the code you posted you were not pulling in src.. Quote Link to comment https://forums.phpfreaks.com/topic/46014-solved-image-resizing-not-working/#findComment-223589 Share on other sites More sharing options...
cmgmyr Posted April 7, 2007 Author Share Posted April 7, 2007 hmmm, the gd library looks like it's working...any other ideas? Quote Link to comment https://forums.phpfreaks.com/topic/46014-solved-image-resizing-not-working/#findComment-223591 Share on other sites More sharing options...
MadTechie Posted April 7, 2007 Share Posted April 7, 2007 is your page live ? ie can i view it online ? Quote Link to comment https://forums.phpfreaks.com/topic/46014-solved-image-resizing-not-working/#findComment-223592 Share on other sites More sharing options...
cmgmyr Posted April 7, 2007 Author Share Posted April 7, 2007 Link Quote Link to comment https://forums.phpfreaks.com/topic/46014-solved-image-resizing-not-working/#findComment-223594 Share on other sites More sharing options...
MadTechie Posted April 7, 2007 Share Posted April 7, 2007 the path to the image is http://rainbowjewelersinc.com/new/thumb.php?src=images/cms_images/6iuf5uxcbheczb0z.jpg&wmax=500&hmax=500 is the code you are using $source = imagecreatefromjpeg($_GET['scr']); //<--updated or $source = imagecreatefromjpeg($src); Quote Link to comment https://forums.phpfreaks.com/topic/46014-solved-image-resizing-not-working/#findComment-223598 Share on other sites More sharing options...
cmgmyr Posted April 7, 2007 Author Share Posted April 7, 2007 i just updated it...still didn't work Quote Link to comment https://forums.phpfreaks.com/topic/46014-solved-image-resizing-not-working/#findComment-223602 Share on other sites More sharing options...
MadTechie Posted April 7, 2007 Share Posted April 7, 2007 test the script from. Works fine! test.php?scr=test.jpg <?php header("Content-type: image/jpeg"); $source = imagecreatefromjpeg($_GET['scr']); //<--updated $orig_w=imagesx($source); $orig_h=imagesy($source); //See if there is a different height and width if(!$_GET['wmax']){ $wmax=100; } if(!$_GET['hmax']){ $hmax=100; } $quality=90; $bgcol=000000; if ($orig_w>$wmax || $orig_h>$hmax) { $thumb_w=$wmax; $thumb_h=$hmax; if ($thumb_w/$orig_w*$orig_h>$thumb_h) $thumb_w=round($thumb_h*$orig_w/$orig_h); else $thumb_h=round($thumb_w*$orig_h/$orig_w); } else { $thumb_w=$orig_w; $thumb_h=$orig_h; } if (!@$bgcol) { $thumb=imagecreatetruecolor($thumb_w,$thumb_h); imagecopyresampled($thumb,$source, 0,0,0,0,$thumb_w,$thumb_h,$orig_w,$orig_h); } else { $thumb=imagecreatetruecolor($wmax,$hmax); imagefilledrectangle($thumb,0,0,$wmax-1,$hmax-1,intval($bgcol,16)); imagecopyresampled($thumb,$source, round(($wmax-$thumb_w)/2),round(($hmax-$thumb_h)/2), 0,0,$thumb_w,$thumb_h,$orig_w,$orig_h); } if (!@$quality) $quality=90; imagejpeg($thumb,"",$quality); imagedestroy($thumb); ?> NOTE THE CHANGE $source = imagecreatefromjpeg($_GET['scr']); Quote Link to comment https://forums.phpfreaks.com/topic/46014-solved-image-resizing-not-working/#findComment-223609 Share on other sites More sharing options...
cmgmyr Posted April 7, 2007 Author Share Posted April 7, 2007 yes i already change it to _get and it still didn't work...I copied the whole code over again and it still didn't work Quote Link to comment https://forums.phpfreaks.com/topic/46014-solved-image-resizing-not-working/#findComment-223610 Share on other sites More sharing options...
MadTechie Posted April 7, 2007 Share Posted April 7, 2007 oooow something wired i linked my test script to your page this WORKED TEST.php?scr=http://rainbowjewelersinc.com/new/images/top.jpg This FAILED TEST.php?scr=http://rainbowjewelersinc.com/new/images/cms_images/6iuf5uxcbheczb0z.jpg error Allowed memory size of 16777216 bytes exhausted on this line $source = imagecreatefromjpeg($_GET['scr']); Quote Link to comment https://forums.phpfreaks.com/topic/46014-solved-image-resizing-not-working/#findComment-223611 Share on other sites More sharing options...
cmgmyr Posted April 7, 2007 Author Share Posted April 7, 2007 hmm...i'll resize them in photoshop and re-upload them with a lower file size and see if it works... Quote Link to comment https://forums.phpfreaks.com/topic/46014-solved-image-resizing-not-working/#findComment-223619 Share on other sites More sharing options...
MadTechie Posted April 7, 2007 Share Posted April 7, 2007 could be a formatting issule.. i had a problem with that before.. anyways i hope it resolved the problem.. PS Nice looking site Quote Link to comment https://forums.phpfreaks.com/topic/46014-solved-image-resizing-not-working/#findComment-223621 Share on other sites More sharing options...
cmgmyr Posted April 7, 2007 Author Share Posted April 7, 2007 thanks for the help and thank about the site Quote Link to comment https://forums.phpfreaks.com/topic/46014-solved-image-resizing-not-working/#findComment-223623 Share on other sites More sharing options...
MadTechie Posted April 7, 2007 Share Posted April 7, 2007 Happy to Help please click solved Quote Link to comment https://forums.phpfreaks.com/topic/46014-solved-image-resizing-not-working/#findComment-223626 Share on other sites More sharing options...
cmgmyr Posted April 7, 2007 Author Share Posted April 7, 2007 re-uploaded a few images to a smaller file size...still nothing Quote Link to comment https://forums.phpfreaks.com/topic/46014-solved-image-resizing-not-working/#findComment-223633 Share on other sites More sharing options...
cmgmyr Posted April 9, 2007 Author Share Posted April 9, 2007 I just made a new thumb code with a few less things and it worked...o well Quote Link to comment https://forums.phpfreaks.com/topic/46014-solved-image-resizing-not-working/#findComment-225421 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.