I have something that does it but only with gif since I have the old version of GDLib. But everthing is the same except for the output and the opening from a specific file.. It's not exactly what you are looking for but it will get you started.... I use a db clas for my db calls so dont try and use does. You will have to change them.
I also build some images on the fly from data.... Take a look at http://www.rconline.ca/wind/index.php?id=1&club_id=0 It is built on the fly using GDLib <?php require("/lib/util.php"); $sql = new MySQL_class; $sql->Create("mydb"); if (isset($_POST['action'])) { /* Update the database records */ $sql->Insert("INSERT INTO photo_item (unum, cat, cutline, create_date, hsize, vsize) VALUES ( $HTTP_COOKIE_VARS[unum], $_POST[cat], '$_POST[cutline]', now(), 0,0)"); $affected_rows = $sql->a_rows; $lastid = mysql_insert_id(); /* If we have an photo let's move it */ if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { move_uploaded_file($_FILES['userfile']['tmp_name'], "pics/$lastid.gif"); } else { /* No photo then send error and delete db entry */ $sql->Delete("DELETE from photo_item where id = $lastid"); echo ("Error no photo uploaded"); Die(); } $imagehw = GetImageSize("pics/$lastid.gif"); $imagewidth = $imagehw[0]; $imageheight = $imagehw[1]; $imagetype = $imagehw[2]; if ($imagetype != 1) { $sql->Delete("DELETE from photo_item where id = $lastid"); $err = unlink ("pics/$lastid.gif"); echo ("Photos must be of type .GIF"); Die(); } // Make sure the pic is at least 250X175 if (($imageheight < 250) AND ($imagewidth < 175)) { $sql->Delete("DELETE from photo_item where id = $lastid"); $err = unlink ("pics/$lastid.gif"); echo ("Photos should be a minimum of 250x175 pixels"); Die(); } if (($imageheight < 175) AND ($imagewidth < 250)) { $sql->Delete("DELETE from photo_item where id = $lastid"); $err = unlink ("pics/$lastid.gif"); echo ("Photos should be a minimum of 250x175 pixels"); Die(); } // Create or source image for scaling and thumbnail $src_img=ImageCreateFromGif("pics/$lastid.gif"); if (($imageheight > 600) or ($imagewidth > 600)) { // We need to scale it if ($imageheight > $imagewidth) { // We have a vertical $hscale = ($imageheight / 600); $new_w = round($imageheight / $hscale); $new_h = round($imageheight / $hscale); } else { // We have a horizontal or square $hscale = ($imagewidth / 600); $new_w = round($imagewidth / $hscale); $new_h = round($imageheight / $hscale); } $dst_img=ImageCreate($new_w,$new_h); ImageCopyResized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,$imagewidth,$imageheight); ImageGif($dst_img, "pics/$lastid.gif"); ImageDestroy($dst_img); } else { // Keep original dimensions $new_w = $imagewidth; $new_h = $imageheight; } // Let's see if it's vertical or horizontal and create thumbnail scale if ($imageheight > $imagewidth) { // We have a vertical $tscale = ($imageheight / 250); $new_tw = round($imagewidth / $tscale); $new_th = round($imageheight / $tscale); } else { // We have a horizontal or square $tscale = ($imagewidth / 250); $new_tw = round($imagewidth / $tscale); $new_th = round($imageheight / $tscale); } // Make the thumbnail $t_img=ImageCreate($new_tw,$new_th); ImageCopyResized($t_img,$src_img,0,0,0,0,$new_tw,$new_th,$imagewidth,$imageheight); ImageGif($t_img, "pics/t$lastid.gif"); // Clean house ImageDestroy($t_img); ImageDestroy($src_img); $sql->Update("update photo_item set hsize = $new_w, vsize = $new_h where id = $lastid"); header("Location: /photos/index.php"); } else { echo "<HTML>"; echo "<HEAD>"; echo "<TITLE>Photo Add</TITLE>"; echo "<link href=\"/style.html\" rel=\"stylesheet\" type=\"text/css\">"; echo "</HEAD>"; echo "<BODY background=\"/images/main-bg.jpg\" bgproperties=\"fixed\">"; echo "<center>"; echo "<h1>Add a photo</h1>\n<p>\n\n"; echo "<form action=\"\" enctype=\"multipart/form-data\" method=\"post\">"; echo "<input type=\"hidden\" name=\"action\" value=\"1\">"; echo "<TABLE border=\"0\">"; echo "<tr>"; echo "<td colspan=\"2\"><img src=\"/images/bpix.gif\" width=\"100%\" height=\"2\"></td>"; echo "</tr>"; echo "<tr>"; echo "<td>Category: </td> <td><select name=\"cat\">"; $sql2 = new MySQL_class; $sql2->Create("mydb"); $sql2->Query("Select id, name from photo_cat order by id"); for ($i = 0; $i < $sql2->rows; $i++) { $sql2->Fetch($i); $id = $sql2->data[id]; $name = $sql2->data[name]; echo("<OPTION VALUE=\"$id\">$name\n"); } echo "</select>"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td valign=\"top\">Cutline:</td> <td><textarea cols=\"50\" rows=\"10\" name=\"cutline\"></textarea></td>"; echo "</tr>"; echo "<tr><td>"; echo "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"1000000\">"; echo "Photo: </td> <td><input name=\"userfile\" type=\"file\">"; echo "</td></tr>"; echo "<tr><td> </td><td>"; echo "<br>Images should be of type .gif"; echo "<br>Resolution should be 75 dpi"; echo "<br>Weight cannot exceed 1Mb"; echo "<br>If possible keep a 3x2 ratio. (600x400 pixels is optimum)"; echo "</td></tr>"; echo "<tr>"; echo "<td colspan=\"4\"><img src=\"/images/bpix.gif\" width=\"100%\" height=\"2\"></td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan=\"4\" align=\"center\"><input type=\"submit\" value=\"Submit\"></td>"; echo "</tr>"; echo "</table>"; echo "</form>"; echo "</center>"; echo "</BODY>"; echo "</HTML>"; } ?> *********** REPLY SEPARATOR *********** On 03/01/2003 at 11:58 AM Michael Weiner wrote: >Does someone have a script of php function or page that has this code >working that i can review? I am wanting to create a webpage that will >let a user enter in an image name (i.e. a png or whatever) and have php >create an image from that... > >Thanks in advance >Michael Weiner > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php