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' ) ; ?> Link to comment https://forums.phpfreaks.com/topic/150407-help-with-image-resize/ 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. Link to comment https://forums.phpfreaks.com/topic/150407-help-with-image-resize/#findComment-789895 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 Link to comment https://forums.phpfreaks.com/topic/150407-help-with-image-resize/#findComment-789909 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.