note 58795 added to function.imagecreate

From: Date: Wed, 16 Nov 2005 09:22:51 +0000
Subject: note 58795 added to function.imagecreate
Groups: php.notes 
Request: Send a blank email to php-notes+get-98647@lists.php.net to get a copy of this message
hey, i've made a resize script. It previously worked, but now the function just stops on the function createimage. also tried createimagetruecolor or createfromjpeg. non of them works now but they did before. i don't get errors either. what seems to be the problem? function create_new_image ($type, $afb_max, $afb_file, $afb_dir, $quality){ $afb_file = $afb_dir.$afb_file; $afb_ext = substr($afb_file, -4); if ($afb_ext == ".jpg" or $afb_ext == ".JPG") { $size = @getimagesize($afb_file); $photo_width = $size[0]; $photo_height = $size[1]; echo $photo_width; $photo = @imagecreate($photo_width, $photo_height); echo "hallo4"; // this echo doesnt show, so he stops after the imagecreate... $afb_naam = basename($afb_file, ".jpg");} else{ echo "Wrong filetype. We only accept jpg-files...<br>"; } if ($type == 1){ $afb_pre_naam = "_width_".date("d-m-Y_H\ui-s\sec"); //zet datum en tijd bij herschaalde afbeelding if ($photo_width == $photo_height){ $new_height = $afb_max; $new_width = $afb_max; } else{ $value = $photo_width / $afb_max; $new_width = $afb_max; $new_height = @round ($photo_height / $value); } } elseif ($type == 2){ $afb_pre_naam = "_height_".date("d-m-Y_H\ui-s\sec"); //zet datum en tijd bij herschaalde afbeelding if ($photo_width == $photo_height){ $new_width = $afb_max; $new_height = $afb_max; } else{ $value = $photo_height / $afb_max; $new_height = $afb_max; $new_width = @round ($photo_width / $value); } } else{ $afb_pre_naam = "_percent_".date("d-m-Y_H\ui-s\sec"); //zet datum en tijd bij de herschaalde afbeelding $new_width = @round ($photo_width / 100 * $afb_max); $new_height = @round ($photo_height / 100 * $afb_max); } $create_blank = @imagecreate($new_width, $new_height); @imagecopyresized($create_blank, $photo, 0, 0, 0, 0, $new_width, $new_height, $photo_width, $photo_height); $new_filename = ''.$afb_dir.''.$afb_naam.''.$afb_pre_naam.''.$afb_ext.''; if ($afb_ext == ".jpg" or $afb_ext == ".JPG") { imagejpeg($create_blank,$new_filename,$quality);} if ($afb_ext == ".png" or $afb_ext == ".PNG") { imagepng($create_blank,$new_filename);} if ($afb_ext == ".jpg" or $afb_ext == ".JPG" or $afb_ext == ".png" or $afb_ext == ".PNG"){ $afb_dir=substr($afb_dir, -12); $new_filename = ''.$afb_dir.''.$afb_naam.''.$afb_pre_naam.''.$afb_ext.''; echo "Right Click on the photo and choose Save Picture As!<BR>"; echo "<BR><img src='".$new_filename."'><BR>"; } } if(isset($_POST["submit"])){ $pad_img = '/home/viggen/public_html/ABC/images/'; if($_FILES["picture1"]['name']!=""){ if($_POST["pixels"]!=""){ //checking width or height if(isset($_POST["radiobutton"])){ if($_POST["radiobutton"]=="wide"){ $type=1; } else{ $type=2; } $afmeting = $_POST["pixels"]; echo "<BR>Image(s) resized to ".$afmeting." pixels.<BR>"; } else{ echo "Error: no radiobutton"; } } else{ $type=3; $afmeting = $_POST["percent"]; echo "<BR><b>Image(s) resized to ".$afmeting." percent size.</b><BR>"; } } else{ echo "Error: You need to select a picture."; } $i=1; while($i<9){ $variabel="picture".$i; if($_FILES[$variabel]['name']!=""){ $variabel2=$_FILES[$variabel]['name']; if (! copy ($_FILES[$variabel]['tmp_name'], $pad_img.$variabel2) ) { $error = "Problem uploading file"; return; } create_new_image ($type, $afmeting, $variabel2, $pad_img, 60); } $i++; } } else{ echo "Submit did not succeed, check your network settings/speed."; } ---- Manual Page -- http://www.php.net/manual/en/function.imagecreate.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+58795 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58795&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58795&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58795&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58795&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58795&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58795&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58795&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+58795&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#98647) next »