jaymc Posted September 19, 2006 Share Posted September 19, 2006 This script is supposed to read a directory full of images, manipulate them and then save them into another DIRIt is working, but, for some reason its only working for the last image of the LoopHere is the code, see if you can see the problem[code]<?$opendir = opendir("pics");$c=1;while ($readdir = readdir($opendir)){ // Get new sizes list($newwidth, $newheight) = getimagesize($readdir); // Load $source = imagecreatefromjpeg($readdir); $max_width = 500; $max_height = 700; $origwidth = imagesx($source); $origheight = imagesy($source);/* if (imagesx($source) > $max_width || imagesy($source) > $max_height) { if ($max_height / $origheight < $max_width / $origwidth) { $scale = $max_height / $origheight; } if ($max_width / $origwidth < $max_height / $origheight) { $scale = $max_width / $origwidth; } $height = $scale * $origheight; $width = $scale * $origwidth; } else {*/ $width = $origwidth; $height = $origheight; $thumb = imagecreatetruecolor($width, $height); // Resize imagecopyresampled ($thumb, $source, 0, 0, 0, 0, $width, $height, $origwidth, $origheight); // Output imagejpeg($thumb,"userimages/$readdir"); echo "$c - $readdir<BR>"; $c++;}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/21294-huh-wierd-problem/ 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.