2 /* This program is free software. It comes without any warranty, to
3 * the extent permitted by applicable law. You can redistribute it
4 * and/or modify it under the terms of the Do What The Fuck You Want
5 * To Public License, Version 2, as published by Sam Hocevar. See
6 * http://sam.zoy.org/wtfpl/COPYING for more details. */
9 function configure_image() {
11 global $db,$error,$node;
12 $user_id=$_SESSION['user_id'];
14 if ($node['node_permission']=='owner') {
16 if (!empty($_FILES['description_image']['tmp_name'])) {
17 $image_tmp=$_FILES['description_image']['tmp_name'];
18 $image_name=$_FILES['description_image']['name'];
20 if ($node['node_id']==$user_id) $width=50;
21 else $width=NODE_IMAGE_WIDTH;
25 $output_image = "images/nodes/".substr($node['node_id'],0,1)."/".substr($node['node_id'],1,1)."/".$node['node_id'].".gif";
27 if (stristr($image_name,".jpg") || stristr($image_name,".jpeg") || stristr($image_name,".gif")){
29 // $cmd=UTILZ_DIR."/jpegtopnm $image |".UTILZ_DIR."/pnmscale -width=$width | ".UTILZ_DIR."ppmquant 256 |".UTILZ_DIR."ppmtogif >".SYSTEM_ROOT."images/nodes/".substr($node['node_id'],0,1)."/".substr($node['node_id'],1,1)."/".$node['node_id'].".gif";
30 // workaround by mifo:
31 if (stristr($image_name,".jpg") || stristr($image_name,".jpeg"))
32 $orig = imagecreatefromjpeg($image_tmp);
34 if (stristr($image_name,".gif"))
35 $orig = imagecreatefromgif($image_tmp);
39 $orig_x = imagesx($orig);
40 $orig_y = imagesy($orig);
41 // if ($orig_x > $width)
44 $image_y = round(($orig_y * $image_x) / $orig_x);
46 $image = imagecreatetruecolor($image_x, $image_y);
47 imagecopyresampled($image, $orig, 0, 0, 0, 0, $image_x, $image_y, $orig_x, $orig_y);
48 // echo $output_image;
49 imagegif($image, $output_image);