Kyberia v2.0
[mirrors/Kyberia-bloodline.git] / inc / eventz / configure_image.inc
1 <?php
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. */
7
8
9 function configure_image() {
10
11 global $db,$error,$node;
12 $user_id=$_SESSION['user_id'];
13
14 if ($node['node_permission']=='owner') {
15
16 if (!empty($_FILES['description_image']['tmp_name'])) {
17 $image_tmp=$_FILES['description_image']['tmp_name'];
18 $image_name=$_FILES['description_image']['name'];
19
20 if ($node['node_id']==$user_id) $width=50;
21 else $width=NODE_IMAGE_WIDTH;
22
23 // mifo:
24
25 $output_image = "images/nodes/".substr($node['node_id'],0,1)."/".substr($node['node_id'],1,1)."/".$node['node_id'].".gif";
26
27 if (stristr($image_name,".jpg") || stristr($image_name,".jpeg") || stristr($image_name,".gif")){
28 // mifo:
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);
33
34 if (stristr($image_name,".gif"))
35 $orig = imagecreatefromgif($image_tmp);
36
37 if ($orig)
38 {
39 $orig_x = imagesx($orig);
40 $orig_y = imagesy($orig);
41 // if ($orig_x > $width)
42 $image_x = $width;
43
44 $image_y = round(($orig_y * $image_x) / $orig_x);
45
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);
50 }
51
52
53
54 }
55 //if ($cmd) {
56 // shell_exec($cmd);
57 //}
58
59 }
60
61 }
62 return true;
63 }
64
65 ?>
This page took 0.301264 seconds and 4 git commands to generate.