function makeBlankImage($width = 4, $height = 7)
{
    //bild generieren
    $ImageOut = ImageCreate($width, $height);
    $White = ImageColorAllocate($ImageOut, 255, 255, 255);
    $FC = $White;
    $BG = $White;
    $TC = $BG;
    ImageColorTransparent($ImageOut, $TC);
    ImageFill($ImageOut, 0, 0, $BG);
    Imageinterlace($ImageOut, 1);
    return $ImageOut;
}
Esempio n. 2
0
/* Set up image */
$imWidth = 480;
$imHeight = 320;
$border = 10;
$graphWidth = $imWidth - $border;
$graphHeight = $imHeight - $border - 30;
$myImage = ImageCreate($imWidth, $imHeight);
$white = ImageColorAllocate($myImage, 255, 255, 255);
$black = ImageColorAllocate($myImage, 0, 0, 0);
$lightgrey = ImageColorAllocate($myImage, 220, 220, 220);
$grey = ImageColorAllocate($myImage, 200, 200, 200);
$blue = ImageColorAllocate($myImage, 0, 0, 255);
$black = ImageColorAllocate($myImage, 0, 0, 0);
$background = ImageColorAllocate($myImage, 240, 240, 240);
ImageFill($myImage, 0, 0, $background);
Imageinterlace($myImage, 1);
$width = ($graphWidth - $border) / count($data) - 1;
$i = $border;
$base = $border + $graphHeight;
$top = $border;
$left = $border;
$right = $graphWidth;
imageline($myImage, $left, $base - $unit, $right, $base - $unit, $black);
imagerectangle($myImage, $left, $top, $right, $base, $black);
$maximum = $max;
#$size = 0-(strlen($max)-1);
#$max = round($max+($max/2),-2);
$max = round(ceil($max / 100)) * 100;
$size = $graphHeight / $max;
$currentleft = $left;
$currentup = $base;
Esempio n. 3
0
function resize_Image($img, $max_width, $max_height)
{
    $size = GetImageSize($img);
    $width = $size[0];
    $height = $size[1];
    $x_ratio = $max_width / $width;
    $y_ratio = $max_height / $height;
    if ($width <= $max_width && $height <= $max_height) {
        $tn_width = $width;
        $tn_height = $height;
    } else {
        if ($x_ratio * $height < $max_height) {
            $tn_height = ceil($x_ratio * $height);
            $tn_width = $max_width;
        } else {
            $tn_width = ceil($y_ratio * $width);
            $tn_height = $max_height;
        }
    }
    if ($size[2] == 1) {
        $src = ImageCreateFromGIF($img);
    }
    if ($size[2] == 2) {
        $src = ImageCreateFromJPEG($img);
    }
    if ($size[2] == 3) {
        $src = ImageCreateFromPNG($img);
    }
    $dst = ImageCreateTrueColor($tn_width, $tn_height);
    ImageCopyResampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height, $width, $height);
    Imageinterlace($dst, 1);
    ImageDestroy($src);
    return $dst;
}
Esempio n. 4
0
 /**
  * main scale function
  *
  * @param string $source
  *        	url to file
  * @param array $params
  *        	params array
  * @param bool $no_cache
  *        	overwrite existing files
  *        	
  * @return string
  */
 public function rimg($source, $params, $no_cache = FALSE)
 {
     $source = trim($source);
     if (file_exists($this->ci->config->config['img_base_path'] . '/' . $source)) {
         $source = $this->ci->config->config['img_base_path'] . '/' . $source;
     } else {
         $path_parts = pathinfo($source);
         $source = $path_parts['dirname'] . '/' . $path_parts['basename'];
     }
     if (!is_file($source)) {
         return "no image: {$source}";
         die;
     }
     $info = @getimagesize($source);
     if (empty($info)) {
         return "not an image";
         die;
     }
     $src['width'] = $info[0];
     $src['height'] = $info[1];
     // default $dst
     $dst = array('offset_w' => 0, 'offset_h' => 0);
     // default values, null them to avoid empty indexes later
     $def = array('longside', 'shortside', 'crop', 'width', 'height', 'sharpen', 'nocache', 'frame');
     if (empty($params['r'])) {
         $params['r'] = 255;
     }
     if (empty($params['g'])) {
         $params['g'] = 255;
     }
     if (empty($params['b'])) {
         $params['b'] = 255;
     }
     // set default paramteres
     foreach ($def as $v) {
         if (!isset($params[$v])) {
             $params[$v] = NULL;
         }
     }
     // if width & height -> assign them to dest
     if (!empty($params['width'])) {
         $dst['width'] = intval($params['width']);
     }
     if (!empty($params['height'])) {
         $dst['height'] = intval($params['height']);
     }
     // if alt is empty, setup file name - bad idea ;)
     if (empty($params['alt'])) {
         $params['alt'] = basename($source);
     } else {
         $params['alt'] = htmlentities($params['alt']);
     }
     // scale to long side
     if (is_numeric($params['longside'])) {
         if ($src['width'] < $src['height']) {
             $dst['height'] = $params['longside'];
             $dst['width'] = round($params['longside'] / ($src['height'] / $src['width']));
         } else {
             $dst['width'] = $params['longside'];
             $dst['height'] = round($params['longside'] / ($src['width'] / $src['height']));
         }
     }
     // scale to shortside
     if (is_numeric($params['shortside'])) {
         if ($src['width'] < $src['height']) {
             $dst['width'] = $params['shortside'];
             $dst['height'] = round($params['shortside'] / ($src['width'] / $src['height']));
         } else {
             $dst['height'] = $params['shortside'];
             $dst['width'] = round($params['shortside'] / ($src['height'] / $src['width']));
         }
     }
     // crop yes / no
     if ($params['crop'] === TRUE) {
         $width_ratio = $src['width'] / $dst['width'];
         $height_ratio = $src['height'] / $dst['height'];
         if ($width_ratio > $height_ratio) {
             $dst['offset_w'] = round(($src['width'] - $dst['width'] * $height_ratio) / 2);
             $src['width'] = round($dst['width'] * $height_ratio);
         } elseif ($width_ratio < $height_ratio) {
             $dst['offset_h'] = round(($src['height'] - $dst['height'] * $width_ratio) / 2);
             $src['height'] = round($dst['height'] * $width_ratio);
         }
     }
     // fill empty space around image
     if ($params['frame'] === TRUE) {
         $src['ratio'] = $src['width'] / $src['height'];
         $params['ratio'] = $params['width'] / $src['height'];
         if ($src['width'] > $src['height']) {
             if ($params['height'] / $src['ratio'] < $params['ratio'] or round($params['width'] / $src['ratio']) > $params['height']) {
                 $dst['width'] = round($params['height'] * $src['ratio']);
                 $dst['height'] = $params['height'];
             } else {
                 $dst['width'] = $params['width'];
                 $dst['height'] = round($params['width'] / $src['ratio']);
             }
         } else {
             if ($params['height'] / $src['ratio'] < $params['ratio'] or round($params['height'] * $src['ratio']) > $params['width']) {
                 $dst['width'] = $params['width'];
                 $dst['height'] = round($params['width'] / $src['ratio']);
             } else {
                 $dst['width'] = round($params['height'] * $src['ratio']);
                 $dst['height'] = $params['height'];
             }
         }
     }
     // create destination directory width x height or longside
     if (!empty($params['longside'])) {
         $dir = '/l' . $params['longside'];
     } else {
         if (!empty($params['shortside'])) {
             $dir = '/s' . $params['shortside'];
         } else {
             if (!empty($param['crop'])) {
                 $dir = "/c{$dst['width']}x{$dst['height']}";
             } else {
                 $dir = "/{$dst['width']}x{$dst['height']}";
             }
         }
     }
     // check if cache path exists
     if (!is_dir($this->ci->config->config['img_base_path'] . $dir)) {
         if (is_writable($this->ci->config->config['img_base_path'])) {
             mkdir($this->ci->config->config['img_base_path'] . $dir);
         } else {
             die('Unable to create cache dir in ' . $this->ci->config->config['img_base_path']);
         }
     }
     // full path to final file
     $dst['file'] = $this->ci->config->config['img_base_path'] . $dir . "/" . basename($source);
     $extra_parameters = '';
     // extra parameters
     if (!empty($params['class'])) {
         $extra_parameters .= "class=\"{$params['class']}\"";
     }
     // id src width & height = dst by-pass
     if ($src['width'] === $dst['width'] && $src['height'] === $dst['height']) {
         return "<img src=\"{$this->ci->config->config['img_base_url']}/" . basename($dst['file']) . "\" width=\"{$dst['width']}\" height=\"{$dst['height']}\" alt=\"{$params['alt']}\" {$extra_parameters}/>";
     }
     // if file exists - return img info
     if (file_exists($dst['file']) and $params['nocache'] !== TRUE) {
         return "<img src=\"{$this->ci->config->config['img_base_url']}{$dir}/" . basename($dst['file']) . "\" width=\"{$dst['width']}\" height=\"{$dst['height']}\" alt=\"{$params['alt']}\" {$extra_parameters}/>";
     }
     $this->_memory_prepare($info);
     // create dst img
     switch ($info[2]) {
         case 1:
             $src['image'] = imagecreatefromgif($source);
             break;
         case 2:
             $src['image'] = imagecreatefromjpeg($source);
             break;
         case 3:
             $src['image'] = imagecreatefrompng($source);
             break;
     }
     if ($dst['width'] * 4 < $src['width'] and $dst['height'] * 4 < $src['height']) {
         $_TMP['width'] = round($dst['width'] * 4);
         $_TMP['height'] = round($dst['height'] * 4);
         $_TMP['image'] = imagecreatetruecolor($_TMP['width'], $_TMP['height']);
         imagecopyresized($_TMP['image'], $src['image'], 0, 0, $dst['offset_w'], $dst['offset_h'], $_TMP['width'], $_TMP['height'], $src['width'], $src['height']);
         $src['image'] = $_TMP['image'];
         $src['width'] = $_TMP['width'];
         $src['height'] = $_TMP['height'];
         $dst['offset_w'] = 0;
         $dst['offset_h'] = 0;
         unset($_TMP['image']);
     }
     $dst['image'] = imagecreatetruecolor($dst['width'], $dst['height']);
     imagecopyresampled($dst['image'], $src['image'], 0, 0, $dst['offset_w'], $dst['offset_h'], $dst['width'], $dst['height'], $src['width'], $src['height']);
     if ($params['sharpen'] !== FALSE) {
         $dst['image'] = $this->unsharp_mask($dst['image'], 80, 0.5, 3);
     }
     if ($params['frame'] === TRUE) {
         $dst_off_h = floor(($params['height'] - $dst['height']) / 2);
         $dst_off_w = round(($params['width'] - $dst['width']) / 2);
         $currimg = $dst['image'];
         $dst['image'] = imagecreatetruecolor($params['width'], $params['height']);
         $bgcolor = imagecolorallocate($dst['image'], $params['r'], $params['g'], $params['b']);
         imagefill($dst['image'], 0, 0, $bgcolor);
         imagecopyresized($dst['image'], $currimg, $dst_off_w, $dst_off_h, 0, 0, $dst['width'], $dst['height'], $dst['width'], $dst['height']);
         $dst['width'] = $params['height'];
         $dst['height'] = $params['width'];
     }
     $dst['type'] = $info[2];
     switch ($dst['type']) {
         case 1:
             imagetruecolortopalette($src['image'], false, 256);
             imagegif($dst['image'], $dst['file']);
             break;
         case 2:
             Imageinterlace($dst['image'], 1);
             if (empty($params['quality'])) {
                 $params['quality'] = 85;
             }
             imagejpeg($dst['image'], $dst['file'], $params['quality']);
             break;
         case 3:
             imagepng($dst['image'], $dst['file']);
             break;
     }
     imagedestroy($dst['image']);
     imagedestroy($src['image']);
     return "<img src=\"{$this->ci->config->config['img_base_url']}{$dir}/" . basename($dst['file']) . "\" width=\"{$dst['width']}\" height=\"{$dst['height']}\" alt=\"{$params['alt']}\" {$extra_parameters}/>";
 }
function smarty_function_thumb($params, &$smarty)
{
    // Start time measurement
    if ($params['dev']) {
        if (!function_exists('getmicrotime')) {
            function getmicrotime()
            {
                list($usec, $sec) = explode(" ", microtime());
                return (double) $usec + (double) $sec;
            }
        }
        $time['start'] = getmicrotime();
    }
    // Funktion zum Schärfen
    if (!function_exists('UnsharpMask')) {
        // Unsharp mask algorithm by Torstein Hønsi 2003 (thoensi_at_netcom_dot_no)
        // Christoph Erdmann: changed it a little, cause i could not reproduce the darker blurred image, now it is up to 15% faster with same results
        function UnsharpMask($img, $amount, $radius, $threshold)
        {
            // Attempt to calibrate the parameters to Photoshop:
            if ($amount > 500) {
                $amount = 500;
            }
            $amount = $amount * 0.016;
            if ($radius > 50) {
                $radius = 50;
            }
            $radius = $radius * 2;
            if ($threshold > 255) {
                $threshold = 255;
            }
            $radius = abs(round($radius));
            // Only integers make sense.
            if ($radius == 0) {
                return $img;
                imagedestroy($img);
                break;
            }
            $w = imagesx($img);
            $h = imagesy($img);
            $imgCanvas = $img;
            $imgCanvas2 = $img;
            $imgBlur = imagecreatetruecolor($w, $h);
            // Gaussian blur matrix:
            //	1	2	1
            //	2	4	2
            //	1	2	1
            // Move copies of the image around one pixel at the time and merge them with weight
            // according to the matrix. The same matrix is simply repeated for higher radii.
            for ($i = 0; $i < $radius; $i++) {
                imagecopy($imgBlur, $imgCanvas, 0, 0, 1, 1, $w - 1, $h - 1);
                // up left
                imagecopymerge($imgBlur, $imgCanvas, 1, 1, 0, 0, $w, $h, 50);
                // down right
                imagecopymerge($imgBlur, $imgCanvas, 0, 1, 1, 0, $w - 1, $h, 33.33333);
                // down left
                imagecopymerge($imgBlur, $imgCanvas, 1, 0, 0, 1, $w, $h - 1, 25);
                // up right
                imagecopymerge($imgBlur, $imgCanvas, 0, 0, 1, 0, $w - 1, $h, 33.33333);
                // left
                imagecopymerge($imgBlur, $imgCanvas, 1, 0, 0, 0, $w, $h, 25);
                // right
                imagecopymerge($imgBlur, $imgCanvas, 0, 0, 0, 1, $w, $h - 1, 20);
                // up
                imagecopymerge($imgBlur, $imgCanvas, 0, 1, 0, 0, $w, $h, 16.666667);
                // down
                imagecopymerge($imgBlur, $imgCanvas, 0, 0, 0, 0, $w, $h, 50);
                // center
            }
            $imgCanvas = $imgBlur;
            // Calculate the difference between the blurred pixels and the original
            // and set the pixels
            for ($x = 0; $x < $w; $x++) {
                // each row
                for ($y = 0; $y < $h; $y++) {
                    // each pixel
                    $rgbOrig = ImageColorAt($imgCanvas2, $x, $y);
                    $rOrig = $rgbOrig >> 16 & 0xff;
                    $gOrig = $rgbOrig >> 8 & 0xff;
                    $bOrig = $rgbOrig & 0xff;
                    $rgbBlur = ImageColorAt($imgCanvas, $x, $y);
                    $rBlur = $rgbBlur >> 16 & 0xff;
                    $gBlur = $rgbBlur >> 8 & 0xff;
                    $bBlur = $rgbBlur & 0xff;
                    // When the masked pixels differ less from the original
                    // than the threshold specifies, they are set to their original value.
                    $rNew = abs($rOrig - $rBlur) >= $threshold ? max(0, min(255, $amount * ($rOrig - $rBlur) + $rOrig)) : $rOrig;
                    $gNew = abs($gOrig - $gBlur) >= $threshold ? max(0, min(255, $amount * ($gOrig - $gBlur) + $gOrig)) : $gOrig;
                    $bNew = abs($bOrig - $bBlur) >= $threshold ? max(0, min(255, $amount * ($bOrig - $bBlur) + $bOrig)) : $bOrig;
                    if ($rOrig != $rNew || $gOrig != $gNew || $bOrig != $bNew) {
                        $pixCol = ImageColorAllocate($img, $rNew, $gNew, $bNew);
                        ImageSetPixel($img, $x, $y, $pixCol);
                    }
                }
            }
            return $img;
        }
    }
    $_CONFIG['types'] = array('', '.gif', '.jpg', '.png');
    ### Übergebene Parameter auswerten und verifizieren
    if (empty($params['cache'])) {
        $_CONFIG['cache'] = 'images/cache/';
    } else {
        $_CONFIG['cache'] = $params['cache'];
    }
    if (empty($params['file'])) {
        $smarty->_trigger_fatal_error("thumb: parameter 'file' cannot be empty");
        return;
    }
    if (!file_exists($params['file'])) {
        $smarty->_trigger_fatal_error("thumb: image file does not exist");
        return;
    }
    if (empty($params['link'])) {
        $params['link'] = true;
    }
    if (empty($params['window'])) {
        $params['window'] = true;
    }
    if (empty($params['hint'])) {
        $params['hint'] = true;
    }
    if (empty($params['extrapolate'])) {
        $params['extrapolate'] = true;
    }
    if (empty($params['dev'])) {
        $params['crop'] = false;
    }
    if (empty($params['crop'])) {
        $params['crop'] = true;
    }
    if (empty($params['width']) and empty($params['height']) and empty($params['longside']) and empty($params['shortside'])) {
        $params['width'] = 100;
    }
    if (empty($params['overlay_position'])) {
        $params['overlay_position'] = 9;
    }
    ### Info über Source (SRC) holen
    $temp = getimagesize($params['file']);
    $_SRC['file'] = $params['file'];
    $_SRC['width'] = $temp[0];
    $_SRC['height'] = $temp[1];
    $_SRC['type'] = $temp[2];
    // 1=GIF, 2=JPG, 3=PNG, SWF=4
    $_SRC['string'] = $temp[3];
    $_SRC['filename'] = basename($params['file']);
    $_SRC['modified'] = filemtime($params['file']);
    // Hash erstellen
    $_SRC['hash'] = md5($_SRC['file'] . $_SRC['modified'] . implode('', $params));
    ### Infos über Destination (DST) errechnen
    if (is_numeric($params['width'])) {
        $_DST['width'] = $params['width'];
    } else {
        $_DST['width'] = round($params['height'] / ($_SRC['height'] / $_SRC['width']));
    }
    if (is_numeric($params['height'])) {
        $_DST['height'] = $params['height'];
    } else {
        $_DST['height'] = round($params['width'] / ($_SRC['width'] / $_SRC['height']));
    }
    // Das Größenverhältnis soll erhalten bleiben egal ob das Bild hoch oder querformatig ist.
    if (is_numeric($params['longside'])) {
        if ($_SRC['width'] < $_SRC['height']) {
            $_DST['height'] = $params['longside'];
            $_DST['width'] = round($params['longside'] / ($_SRC['height'] / $_SRC['width']));
        } else {
            $_DST['width'] = $params['longside'];
            $_DST['height'] = round($params['longside'] / ($_SRC['width'] / $_SRC['height']));
        }
    } elseif (is_numeric($params['shortside'])) {
        if ($_SRC['width'] < $_SRC['height']) {
            $_DST['width'] = $params['shortside'];
            $_DST['height'] = round($params['shortside'] / ($_SRC['width'] / $_SRC['height']));
        } else {
            $_DST['height'] = $params['shortside'];
            $_DST['width'] = round($params['shortside'] / ($_SRC['height'] / $_SRC['width']));
        }
    }
    // Soll beschnitten werden? (Standard)
    if ($params['crop']) {
        $width_ratio = $_SRC['width'] / $_DST['width'];
        $height_ratio = $_SRC['height'] / $_DST['height'];
        // Es muss an der Breite beschnitten werden
        if ($width_ratio > $height_ratio) {
            $_DST['offset_w'] = round(($_SRC['width'] - $_DST['width'] * $height_ratio) / 2);
            $_SRC['width'] = round($_DST['width'] * $height_ratio);
        } elseif ($width_ratio < $height_ratio) {
            $_DST['offset_h'] = round(($_SRC['height'] - $_DST['height'] * $width_ratio) / 2);
            $_SRC['height'] = round($_DST['height'] * $width_ratio);
        }
    }
    // Wenn das Ursprungsbild kleiner als das Ziel-Bild ist, soll nicht hochskaliert werden und die neu berechneten Werte werden wieder überschrieben
    if ($params['extrapolate'] == 'false' && $_DST['height'] > $_SRC['height'] && $_DST['width'] > $_SRC['width']) {
        $_DST['width'] = $_SRC['width'];
        $_DST['height'] = $_SRC['height'];
    }
    if (!empty($params['type'])) {
        $_DST['type'] = $params['type'];
    } else {
        $_DST['type'] = $_SRC['type'];
    }
    $_DST['file'] = $_CONFIG['cache'] . $_SRC['hash'] . $_CONFIG['types'][$_DST['type']];
    $_DST['string'] = 'width="' . $_DST['width'] . '" height="' . $_DST['height'] . '"';
    // Gibts evtl. einen Rahmen
    if (!empty($params['frame'])) {
        // schauen obs gültig ist
        $imagesize = getimagesize($params['frame']);
        if ($imagesize[0] != $imagesize[1] or $imagesize[0] % 3 or !file_exists($params['frame'])) {
            $smarty->_trigger_fatal_error("thumb: wrong dimensions of 'frame'-image or width and height is not a multiplier of 3");
            return;
        }
        // Blockgröße brauche ich schon hier, falls ein gecachtes Bild wiedergegeben werden soll
        $frame_blocksize = $imagesize[0] / 3;
        $_DST['string'] = 'width="' . ($_DST['width'] + 2 * $frame_blocksize) . '" height="' . ($_DST['height'] + 2 * $frame_blocksize) . '"';
    }
    ### Rückgabe-Strings erstellen
    if (empty($params['html'])) {
        $_RETURN['img'] = '<img src="' . $_DST['file'] . '" ' . $params['html'] . ' ' . $_DST['string'] . ' alt="" title="" />';
    } else {
        $_RETURN['img'] = '<img src="' . $_DST['file'] . '" ' . $params['html'] . ' ' . $_DST['string'] . ' />';
    }
    if ($params['link'] == "true") {
        if (empty($params['linkurl'])) {
            $params['linkurl'] = $_SRC['file'];
        }
        if ($params['window'] == "true") {
            $returner = '<a href="' . $params['linkurl'] . '" target="_blank">' . $_RETURN['img'] . '</a>';
        } else {
            $returner = '<a href="' . $params['linkurl'] . '">' . $_RETURN['img'] . '</a>';
        }
    } else {
        $returner = $_RETURN['img'];
    }
    ### Cache-Datei abfangen
    if (file_exists($_DST['file']) and !$params['dev']) {
        return $returner;
    }
    ### ansonsten weitermachen
    // SRC einlesen
    if ($_SRC['type'] == 1) {
        $_SRC['image'] = imagecreatefromgif($_SRC['file']);
    }
    if ($_SRC['type'] == 2) {
        $_SRC['image'] = imagecreatefromjpeg($_SRC['file']);
    }
    if ($_SRC['type'] == 3) {
        $_SRC['image'] = imagecreatefrompng($_SRC['file']);
    }
    // Wenn das Bild sehr groß ist, zuerst linear auf vierfache Zielgröße herunterskalieren und $_SRC überschreiben
    if ($_DST['width'] * 4 < $_SRC['width'] and $_DST['height'] * 4 < $_SRC['height']) {
        // Multiplikator der Zielgröße
        $_TMP['width'] = round($_DST['width'] * 4);
        $_TMP['height'] = round($_DST['height'] * 4);
        $_TMP['image'] = imagecreatetruecolor($_TMP['width'], $_TMP['height']);
        imagecopyresized($_TMP['image'], $_SRC['image'], 0, 0, $_DST['offset_w'], $_DST['offset_h'], $_TMP['width'], $_TMP['height'], $_SRC['width'], $_SRC['height']);
        $_SRC['image'] = $_TMP['image'];
        $_SRC['width'] = $_TMP['width'];
        $_SRC['height'] = $_TMP['height'];
        // Wenn vorskaliert wird, darf ja nicht nochmal ein bestimmter Bereich ausgeschnitten werden
        $_DST['offset_w'] = 0;
        $_DST['offset_h'] = 0;
        unset($_TMP['image']);
    }
    // DST erstellen
    $_DST['image'] = imagecreatetruecolor($_DST['width'], $_DST['height']);
    imagecopyresampled($_DST['image'], $_SRC['image'], 0, 0, $_DST['offset_w'], $_DST['offset_h'], $_DST['width'], $_DST['height'], $_SRC['width'], $_SRC['height']);
    if ($params['sharpen'] != "false") {
        $_DST['image'] = UnsharpMask($_DST['image'], 80, 0.5, 3);
    }
    // Soll eine Lupe eingefügt werden?
    if ($params['hint'] == "true") {
        // Soll der weiße Balken wirklich hinzugefügt werden?
        if ($params['addgreytohint'] != 'false') {
            $trans = imagecolorallocatealpha($_DST['image'], 255, 255, 255, 25);
            imagefilledrectangle($_DST['image'], 0, $_DST['height'] - 9, $_DST['width'], $_DST['height'], $trans);
        }
        $magnifier = imagecreatefromstring(gzuncompress(base64_decode("eJzrDPBz5+WS4mJgYOD19HAJAtLcIMzBBiRXrilXA1IsxU6eIRxAUMOR0gHkcxZ4RBYD1QiBMOOlu3V/gIISJa4RJc5FqYklmfl5CiGZuakMBoZ6hkZ6RgYGJs77ex2BalRBaoLz00rKE4tSGXwTk4vyc1NTMhMV3DKLUsvzi7KLFXwjFEAa2svWnGdgYPTydHEMqZhTOsE++1CAyNHzm2NZjgau+dAmXlAwoatQmOld3t/NPxlLMvY7sovPzXHf7re05BPzjpQTMkZTPjm1HlHkv6clYWK43Zt16rcDjdZ/3j2cd7qD4/HHH3GaprFrw0QZDHicORXl2JsPsveVTDz//L3N+WpxJ5Hff+10Tjdd2/Vi17vea79Om5w9zzyne9GLnWGrN8atby/ayXPOsu2w4quvVtxNCVVz5nAf3nDpZckBCedpqSc28WTOWnT7rZNXZSlPvFybie9EFc6y3bIMCn3JAoJ+kyyfn9qWq+LZ9Las26Jv482cDRE6Ci0B6gVbo2oj9KabzD8vyMK4ZMqMs2kSvW4chz88SXNzmeGjtj1QZK9M3HHL8L7HITX3t19//VVY8CYDg9Kvy2vDXu+6mGGxNOiltMPsjn/t9eJr0ja/FOdi5TyQ9Lz3fOqstOr99/dnro2vZ1jy76D/vYivPsBoYPB09XNZ55TQBAAJjs5s</body>")));
        imagealphablending($_DST['image'], true);
        imagecopy($_DST['image'], $magnifier, $_DST['width'] - 15, $_DST['height'] - 14, 0, 0, 11, 11);
        imagedestroy($magnifier);
    }
    // Soll ein Overlay-Bild hinzugefügt werden
    if (!empty($params['overlay'])) {
        // "overlay"-Bild laden
        $overlay = imagecreatefrompng($params['overlay']);
        $overlay_size = getimagesize($params['overlay']);
        // Overlay-Bild an die richtige Stelle kopieren
        if ($params['overlay_position'] == '1') {
            imagecopy($_DST['image'], $overlay, 0, 0, 0, 0, $overlay_size[0], $overlay_size[1]);
        }
        // ecke links oben
        if ($params['overlay_position'] == '2') {
            imagecopy($_DST['image'], $overlay, $_DST['width'] / 2 - $overlay_size[0] / 2, 0, 0, 0, $overlay_size[0], $overlay_size[1]);
        }
        // ecke links oben
        if ($params['overlay_position'] == '3') {
            imagecopy($_DST['image'], $overlay, $_DST['width'] - $overlay_size[0], 0, 0, 0, $overlay_size[0], $overlay_size[1]);
        }
        // ecke links oben
        if ($params['overlay_position'] == '4') {
            imagecopy($_DST['image'], $overlay, 0, $_DST['height'] / 2 - $overlay_size[1] / 2, 0, 0, $overlay_size[0], $overlay_size[1]);
        }
        // ecke links oben
        if ($params['overlay_position'] == '5') {
            imagecopy($_DST['image'], $overlay, $_DST['width'] / 2 - $overlay_size[0] / 2, $_DST['height'] / 2 - $overlay_size[1] / 2, 0, 0, $overlay_size[0], $overlay_size[1]);
        }
        // ecke links oben
        if ($params['overlay_position'] == '6') {
            imagecopy($_DST['image'], $overlay, $_DST['width'] - $overlay_size[0], $_DST['height'] / 2 - $overlay_size[1] / 2, 0, 0, $overlay_size[0], $overlay_size[1]);
        }
        // ecke links oben
        if ($params['overlay_position'] == '7') {
            imagecopy($_DST['image'], $overlay, 0, $_DST['height'] - $overlay_size[1], 0, 0, $overlay_size[0], $overlay_size[1]);
        }
        // ecke links oben
        if ($params['overlay_position'] == '8') {
            imagecopy($_DST['image'], $overlay, $_DST['width'] / 2 - $overlay_size[0] / 2, $_DST['height'] - $overlay_size[1], 0, 0, $overlay_size[0], $overlay_size[1]);
        }
        // ecke links oben
        if ($params['overlay_position'] == '9') {
            imagecopy($_DST['image'], $overlay, $_DST['width'] - $overlay_size[0], $_DST['height'] - $overlay_size[1], 0, 0, $overlay_size[0], $overlay_size[1]);
        }
        // ecke links oben
    }
    // Berechnungszeit hinzufügen
    if ($params['dev']) {
        // Zeit anhalten
        $time['end'] = getmicrotime();
        $time = round($time['end'] - $time['start'], 2);
        // Farben definieren
        $white_trans = imagecolorallocatealpha($_DST['image'], 255, 255, 255, 25);
        $black = ImageColorAllocate($_DST['image'], 0, 0, 0);
        // Weißer Balken oben
        imagefilledrectangle($_DST['image'], 0, 0, $_DST['width'], 10, $white_trans);
        // Schrift mit Zeitangabe
        imagestring($_DST['image'], 1, 5, 2, 'time: ' . $time . 's', $black);
    }
    // Soll ein Rahmen hinzugefügt werden
    if (!empty($params['frame'])) {
        // "frame"-Bild laden und initialisieren
        $frame = imagecreatefrompng($params['frame']);
        $frame_blocksize = $imagesize[0] / 3;
        // Neues Bild erstellen und bisher erzeugtes Bild hereinkopieren
        $_FRAME['image'] = imagecreatetruecolor($_DST['width'] + 2 * $frame_blocksize, $_DST['height'] + 2 * $frame_blocksize);
        imagecopy($_FRAME['image'], $_DST['image'], $frame_blocksize, $frame_blocksize, 0, 0, $_DST['width'], $_DST['height']);
        // Jetzt die ganzen anderen Rahmen herum zeichnen
        // die Ecken
        imagecopy($_FRAME['image'], $frame, 0, 0, 0, 0, $frame_blocksize, $frame_blocksize);
        // ecke links oben
        imagecopy($_FRAME['image'], $frame, $_DST['width'] + $frame_blocksize, 0, 2 * $frame_blocksize, 0, $frame_blocksize, $frame_blocksize);
        // ecke rechts oben
        imagecopy($_FRAME['image'], $frame, $_DST['width'] + $frame_blocksize, $_DST['height'] + $frame_blocksize, 2 * $frame_blocksize, 2 * $frame_blocksize, $frame_blocksize, $frame_blocksize);
        // ecke rechts unten
        imagecopy($_FRAME['image'], $frame, 0, $_DST['height'] + $frame_blocksize, 0, 2 * $frame_blocksize, $frame_blocksize, $frame_blocksize);
        // ecke links unten
        // jetzt die Seiten
        imagecopyresized($_FRAME['image'], $frame, $frame_blocksize, 0, $frame_blocksize, 0, $_DST['width'], $frame_blocksize, $frame_blocksize, $frame_blocksize);
        // oben
        imagecopyresized($_FRAME['image'], $frame, $_DST['width'] + $frame_blocksize, $frame_blocksize, 2 * $frame_blocksize, $frame_blocksize, $frame_blocksize, $_DST['height'], $frame_blocksize, $frame_blocksize);
        // rechts
        imagecopyresized($_FRAME['image'], $frame, $frame_blocksize, $_DST['height'] + $frame_blocksize, $frame_blocksize, 2 * $frame_blocksize, $_DST['width'], $frame_blocksize, $frame_blocksize, $frame_blocksize);
        // unten
        imagecopyresized($_FRAME['image'], $frame, 0, $frame_blocksize, 0, $frame_blocksize, $frame_blocksize, $_DST['height'], $frame_blocksize, $frame_blocksize);
        // links
        $_DST['image'] = $_FRAME['image'];
        $_DST['width'] = $_DST['width'] + 2 * $frame_blocksize;
        $_DST['height'] = $_DST['height'] + 2 * $frame_blocksize;
        $_DST['string2'] = 'width="' . $_DST['width'] . '" height="' . $_DST['height'] . '"';
        $returner = str_replace($_DST['string'], $_DST['string2'], $returner);
    }
    // Thumbnail abspeichern
    if ($_DST['type'] == 1) {
        imagetruecolortopalette($_DST['image'], false, 256);
        imagegif($_DST['image'], $_DST['file']);
    }
    if ($_DST['type'] == 2) {
        Imageinterlace($_DST['image'], 1);
        if (empty($params['quality'])) {
            $params['quality'] = 80;
        }
        imagejpeg($_DST['image'], $_DST['file'], $params['quality']);
    }
    if ($_DST['type'] == 3) {
        imagepng($_DST['image'], $_DST['file']);
    }
    imagedestroy($_DST['image']);
    imagedestroy($_SRC['image']);
    // Und Bild ausgeben
    return $returner;
}
Esempio n. 6
0
$imageHeight = st_getVar("height", 270);
$betweenClause = "";
$orderBy = st_getVar("orderBy", "dd DESC");
if ($time_frame != 4) {
    $betweenClause = " WHERE access_time BETWEEN '{$startDate}' AND '{$endDate}'";
}
//   require("phpPieGraph.php");
// Setup how high and how wide the ouput image is
// Create a new Image
$image = ImageCreate($imageWidth, $imageHeight);
// Fill it with your favorite background color..
$backgroundColor = ImageColorAllocate($image, 255, 255, 255);
ImageFill($image, 0, 0, $backgroundColor);
$text = ImageColorAllocate($image, 0, 0, 0);
// Interlace the image..
Imageinterlace($image, 1);
$totalHits = 0;
// HORZONTAL BAR CHART
if ($chart_type == 'hz_bar') {
    // We need to be able to use the bar graph class in phpBarGraph2.php
    require_once "phpBarGraph2.php";
    // Create a new BarGraph..
    $myBarGraph = new PhpBarGraph();
    $myBarGraph->SetX(10);
    // Set the starting x position
    $myBarGraph->SetY(10);
    // Set the starting y position
    $myBarGraph->SetWidth($imageWidth - 20);
    // Set how wide the bargraph will be
    $myBarGraph->SetHeight($imageHeight - 20);
    // Set how tall the bargraph will be