Freeola_guy Posted January 15, 2007 Share Posted January 15, 2007 i am attempting to resize an jpeg image, which works fine but when it comes to viewing the image, it is replaced with a black image, i believe it mite be that that imagecreatefromjpeg or imagecreatetruecolor functions mite be failing but ive been unable to find any immediate solutions ive included my code below, any suggestions would be much appreciated.function resizeImage($imgfile_name,$uploaddir,$rand){ //ratio to resize $percent = 0.5; $final_filename = str_replace(" ", "_", $imgfile_name); $newfile = ''.$uploaddir .''.$final_filename.''; $destination_file = 'C:/PHP/thumbs/'.$rand.'A.jpg'; // Content type //header('Content-type: image/jpeg'); list($pic_width,$pic_height) = getimagesize($newfile); echo "Image: ".$final_filename." currently has a width: ".$pic_width." and a height: ".$pic_height.""; $new_width = $pic_width * $percent; $new_height = $pic_height * $percent; echo "Image: ".$final_filename." will have a width: ".$new_width." and a height: ".$new_height.""; // Resample $image_p = imagecreatetruecolor($new_width, $new_height); $image = imagecreatefromjpeg($newfile); $resampled = imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $pic_width, $_picheight); // Output imagejpeg($image_p,$destination_file,100); return;} Link to comment https://forums.phpfreaks.com/topic/34232-attempting-to-resize-jpeg-images/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.