EagerWolf Posted February 14, 2007 Share Posted February 14, 2007 Here is my code which should do resize: $wm = $newwidth/$framed_img_w; // Izracunamo razmerje med trenutno novo dolzino slike in zahtevano dolzino slike $hm = $newheight/$framed_img_h; // Izracunamo razmerje med trenutno novo visino slike in zahtevano visino slike $h_height = $framed_img_h/2; // Podamo polovico zahtevane velikosti slike $w_height = $framed_img_w/2; // Podamo polovico zahtevane dolzine slike if($newwidth > $newheight) // V primeru, ko je slika podolgovata { $adjusted_width = $newwidth / $hm; $half_width = $adjusted_width / 2; $int_width = $half_width - $w_height; imagecopyresampled($croped,$resized_img,-$int_width,0,0,0,$adjusted_width,$framed_img_h,$newwidth,$newheight); } elseif(($newwidth < $newheight) || ($newwidth == $newheight)) // V primeru, ko je slika pokoncna ali kvadratna { $adjusted_height = $newheight / $wm; $half_height = $adjusted_height / 2; $int_height = $half_height - $h_height; imagecopyresampled($croped,$resized_img,0,-$int_height,0,0,$framed_img_w,$adjusted_height,$newwidth,$newheight); } $newwidth & $newheight are given by a script above, which resizes image to 300, newheight, or newwidth, 300 pixels. My script works for for images when width > height... When you add image where height > width, image is just resized to 300, 300 pixels... Please help! Quote Link to comment Share on other sites More sharing options...
EagerWolf Posted February 14, 2007 Author Share Posted February 14, 2007 Is it possible, that crop is not avalible as height attribute? Should I rotate for 90 degrees? Quote Link to comment Share on other sites More sharing options...
pkSML Posted February 14, 2007 Share Posted February 14, 2007 Check out thumb.php at http://stephen.calvarybucyrus.org/code/5 Set these two variables (they should be the same) $th_max_width = 250; // Maximum width of the thumbnail $th_max_height = 250; // Maximum height of the thumbnail and call like this: <?php echo "<IMG src=\"thumb.php?file=".$filename."\">"; ?> $filename must be a relative path for the full-size picture. Quote Link to comment Share on other sites More sharing options...
EagerWolf Posted February 14, 2007 Author Share Posted February 14, 2007 Thanks for help! Problem solved! Quote Link to comment 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.