api = true; $this->views = array('empty'); $size = 99; if ($size > 99) { $size=99; } define("HOME_DIR",Config::$System["base_path"] . '/media/img'); define("DEFAULT_IMAGE_SIZE",25); $image_file = Request_Handler::$URL; if (count($image_file) < 2) { $image_file = $image_file[2]; }else{ $image_file = 'bilde_mangler.jpg'; } if (isset($image_file)) { /* These three lines must be on top */ $file = urldecode($image_file); $len = strlen($file); if (substr($file,$len-1,1) == '.') { $file = substr($file,0,$len-1); } /* HERE */ $file_arr = explode('/',$file); $filetype= filetype(sprintf('%s/%s',HOME_DIR,$file)); $file_path = sprintf('%s/%s',HOME_DIR,$file); switch ($filetype) { case "file": $filesize=filesize($file_path); break; case "dir": $file=explode('/',$file); arsort($file); $file=implode('',$file); break; default: $filesize=filesize($file_path); break; } if (isset($_GET["degrees"])) { $degrees = $_GET["degrees"]; }else{ $degrees=0; } }else{ $file = '.'; $filesize = 0; $file_arr = array('.'); $degrees=0; } /* Set size if not auto default it */ if (isset($_GET["size"])) { $size=$_GET["size"]; }else $size = DEFAULT_IMAGE_SIZE; $percent = sprintf('0.%d',$size); $finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension $mime = finfo_file($finfo, $file_path); // Content type header(sprintf('Content-Type: %s',$mime)); // Get new dimensions list($width, $height) = getimagesize($file_path); if ($width < 850 AND $height < 800) { $percent = 1; } // Standard for small pictures $new_width = $width * $percent; $new_height = $height * $percent; if ($new_width < 850 AND $new_height < 800) { $new_width = $width * ($percent+0.30); $new_height = $height * ($percent+0.30); } // Resample $image_p = imagecreatetruecolor($new_width, $new_height); switch ($mime) { case 'image/jpeg': case 'image/jpg': $image = imagecreatefromjpeg($file_path); break; case 'image/png': $image = imagecreatefrompng($file_path); break; case 'image/gif': $image = imagecreatefromgif($file_path); break; } imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); $image_p=imagerotate($image_p, $degrees, 0); // Output switch ($mime) { case 'image/jpeg': case 'image/jpg': imagejpeg($image_p, null, 100); break; case 'image/png': imagepng($image_p, null, 100); break; case 'image/gif': imagegif($image_p, null, 100); break; } } }