pmiller624 Posted March 20, 2009 Share Posted March 20, 2009 ok, what my code does take a image that the user uploaded then takes in and width and height then resizes it. it gets the width and height from the user through textboxes and what is happening is when a user put either zero or nothing into the boxes the image is turned black does anyone know why this is happening. here is what i got <?php session_start(); ?> <?php $filename = $_SESSION['imagename']; $width = $_SESSION['width']; $height = $_SESSION['height']; list($getWidth, $getHeight) = getimagesize("userimages/" . $filename); if($width > 0){ $newWidth = $width; }else{ $newWidth = $getWidth; } if($height > 0){ $newHeight = $height; }else{ $newHeight = $getHeight; } $image_p = imagecreatetruecolor($newWidth, $newHeight); $image = imagecreatefromjpeg("userimages/".$filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height); imagejpeg( $image_p, "userimages/".$filename, 100 ); header( 'Location: setup.php' ) ; ?> Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 20, 2009 Share Posted March 20, 2009 i am guessing here imagecopyresampled($image_p, $image, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height); 6 000000 = black so #000000 is black as safe friendly web color. i guess it normal. use a if($what_ever==0){ $what_ever=defualt_number; } to stop the pic being black. Quote Link to comment Share on other sites More sharing options...
pmiller624 Posted March 20, 2009 Author Share Posted March 20, 2009 thanks for the help but it didnt work 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.