argrafic Posted May 21, 2008 Share Posted May 21, 2008 Hello all, I'm using the script from this site: http://www.theopensurgery.com/29/php-upload-and-resize-image-script/#comment-415 I have it working for jpg and gif, but can't get it to work with png and bmp. Help!! Please!!! Thanks!!! Here's the part of the code that makes the thumbnails: if (isset ($_FILES['gi_imagen'])){ $imagename = $_FILES['gi_imagen']['name'][$i]; $source = $_FILES['gi_imagen']['tmp_name'][$i]; $tipo = $_FILES['gi_imagen']['type'][$i]; echo "<br>Tip: ".$tipo; $target = "../galerias/".$gal."_".$imagename; move_uploaded_file($source, $target); $imagepath = $gal."_".$imagename; $save = "../galerias/".$gal."_"."tn_".$imagename; //thumbnail $file = "../galerias/".$imagepath; //original list($width, $height) = getimagesize($file); $modwidth = 80; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight); if($tipo == "image/pjpeg" || $tipo == "image/jpeg" || $tipo == "image/jpeg" || $tipo == "image/JPG" || $tipo == "image/jpg"){ $image = imagecreatefromjpeg($file); } else if($tipo == "image/gif" || $tipo == "image/GIF"){ $image = imagecreatefromgif($file); } else if($tipo == "image/bmp" || $tipo == "image/BMP"){ $image = imagecreatefromwbmp($file); } else if($tipo == "image/X-PNG" || $tipo == "image/PNG" || $tipo == "image/png" || $tipo == "image/x-png"){ $image = imagecreatefrompng($file); } imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height); if($tipo == "image/pjpeg" || $tipo == "image/jpeg" || $tipo == "image/jpeg" || $tipo == "image/JPG"){ imagejpeg($tn, $save, 100); } else if($tipo == "image/gif" || $tipo == "image/GIF"){ imagegif($tn, $save, 100); } else if($tipo == "image/bmp" || $tipo == "image/BMP"){ imagewbmp($tn, $save, 100); } else if($tipo == "image/X-PNG" || $tipo == "image/PNG" || $tipo == "image/png" || $tipo == "image/x-png"){ imagepng($tn, $save, 100); } echo "<br>Img: ".$img = $imagepath; //imagen final echo "<br>Thmb: ".$thb = $gal."_"."tn_".$imagename; //thumbnail final } Link to comment https://forums.phpfreaks.com/topic/106633-upload-and-thumbnail-creation-png-bmp/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.