Example #1
1
function text2etc($text, $CP, $mode = "png", $trans = 1)
{
    global $TTF_LOCATION, $FONT_SIZE;
    //$outputtext = implode('',file($f));
    $outputtext = $text;
    $outputtext = Conv2UTF8($outputtext, 1, $CP);
    $outputtext = str_replace("\r\n", "\n", $outputtext);
    $outputtext = str_replace("\r", "\n", $outputtext);
    $outputtext = str_replace("\n", "\r\n", $outputtext);
    $outputtext = str_replace("<br />", "\r\n", $outputtext);
    $outputtext = str_replace("&nbsp;", " ", $outputtext);
    $outputtext = unhtmlentities($outputtext);
    if ($mode == "png") {
        $dim = imageftbbox($FONT_SIZE, 0, $TTF_LOCATION, $outputtext, array("linespacing" => 1.0));
        #		$dim= imagettfbbox($FONT_SIZE, 0, $TTF_LOCATION, $outputtext);
        $min_x = min($dim[0], $dim[2], $dim[4], $dim[6]);
        $max_x = max($dim[0], $dim[2], $dim[4], $dim[6]);
        $width = $max_x - $min_x + 1;
        $min_y = min($dim[1], $dim[3], $dim[5], $dim[7]);
        $max_y = max($dim[1], $dim[3], $dim[5], $dim[7]);
        $height = $max_y - $min_y + 1;
        $img = imagecreate($width + 1, $height + 1);
        $white = ImageColorAllocate($img, 255, 255, 255);
        if ($trans) {
            $twhite = imagecolortransparent($img, $white);
        }
        $black = ImageColorAllocate($img, 0, 0, 0);
        #		ImageTTFText($img, $FONT_SIZE, 0, -$min_x+$dim[0],-$min_y, $black, $TTF_LOCATION, $outputtext);
        ImageFTText($img, $FONT_SIZE, 0, -$min_x + $dim[0], -$min_y, $black, $TTF_LOCATION, $outputtext, array("linespacing" => 1.0));
        Header("Content-type: image/png");
        ImagePng($img);
        ImageDestroy($img);
    } else {
        if ($mode == "pre") {
            echo "<pre>\n{$outputtext}\n</pre>";
        } else {
            if ($mode == "text") {
                Header("Content-type: text/plain");
                echo utf8Encode($outputtext);
            }
        }
    }
}
Example #2
0
function init_resultat_election()
{
    global $image, $blanc, $noir, $gris, $gris2;
    header("Content-type: image/png");
    $annee = $_REQUEST[annee];
    $genre = $_REQUEST[genre];
    $type = $_REQUEST[type];
    $lesMiss = selectDbMiss($annee, $genre, $type, "", true);
    usort($lesMiss, "callback_sort_nb_votes");
    $nb = count($lesMiss);
    $hauteur = TAILLE_BARRE * $nb;
    $largeur = TAILLE_HAUTEUR;
    $image = ImageCreate($hauteur, $largeur);
    // On passe en blanc le fond de l'image
    $blanc = imagecolorallocate($image, 255, 255, 255);
    $noir = imagecolorallocate($image, 0, 0, 0);
    $gris = ImageColorAllocate($image, 190, 190, 190);
    $gris2 = ImageColorAllocate($image, 140, 140, 140);
    imagefilledrectangle($image, 0, 0, $largeur, $hauteur, $blanc);
    $total_votes = nombre_votes_db($annee, $genre, $type);
    dessine_nom_results_miss($lesMiss, $total_votes);
    // Génération de l'image
    ImagePng($image);
    // Desctruction de l'image
    ImageDestroy($image);
}
 /**
 * $IMG_WIDTH = 100; //图像宽度
 		$IMG_HEIGHT = 23; //图像高度
 		$SESSION_VDCODE = ''; //Session变量名称
 * $operator =  '+-'; //运算符
 */
 public static function display($IMG_WIDTH = 70, $IMG_HEIGHT = 25, $SESSION_VDCODE = 'vdcode', $operator = '+')
 {
     $session_id = session_id();
     if (empty($session_id)) {
         @session_start();
     }
     $code = array();
     $num1 = $code[] = mt_rand(1, 9);
     $code[] = '+';
     //{mt_rand(0,1)};
     $num2 = $code[] = mt_rand(1, 9);
     $codestr = implode('', $code);
     //eval("\$result = ".implode('',$code).";");
     $code[] = '=';
     $_SESSION[$SESSION_VDCODE] = (int) $num1 + (int) $num2;
     $img = ImageCreate($IMG_WIDTH, $IMG_HEIGHT);
     ImageColorAllocate($img, mt_rand(230, 250), mt_rand(230, 250), mt_rand(230, 250));
     $color = ImageColorAllocate($img, 0, 0, 0);
     $offset = 0;
     foreach ($code as $char) {
         $offset += 15;
         $txtcolor = ImageColorAllocate($img, mt_rand(0, 255), mt_rand(0, 150), mt_rand(0, 255));
         ImageChar($img, mt_rand(3, 5), $offset, mt_rand(1, 5), $char, $txtcolor);
     }
     for ($i = 0; $i < 100; $i++) {
         $pxcolor = ImageColorAllocate($img, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         ImageSetPixel($img, mt_rand(0, $IMG_WIDTH), mt_rand(0, $IMG_HEIGHT), $pxcolor);
     }
     header('Content-type: image/png');
     ImagePng($img);
     exit;
 }
 function guvenlik_resmi()
 {
     $sifre = substr(md5(rand(0, 999999999999)), -5);
     if ($sifre) {
         $this->session->set_userdata('koruma', $sifre);
         $yukseklik = 62;
         $genislik = 200;
         $resim = ImageCreate($genislik, $yukseklik);
         $siyah = ImageColorAllocate($resim, 0, 0, 0);
         $kirmizi = ImageColorAllocate($resim, 182, 16, 99);
         $beyaz = ImageColorAllocate($resim, 255, 255, 255);
         ImageFill($resim, 0, 0, $beyaz);
         $font = 'css/comic.ttf';
         $font_boyut = 24;
         $sM = 30;
         $uM = 45;
         //kullanımı
         //resim adı, font boyutu, yazının açısı, yazının soldan margini, üstten margin, renk, font adı, şifrenin hangi digitinin yazılacağı bellirtiliyor
         imagettftext($resim, $font_boyut, rand(-45, 45), $sMa = $sM, $uM, rand(0, 255), $font, $sifre[0]);
         imagettftext($resim, $font_boyut, rand(-45, 45), $sM = $sMa + $sM, $uM, rand(0, 255), $font, $sifre[1]);
         imagettftext($resim, $font_boyut, rand(-45, 45), $sM = $sMa + $sM, $uM, rand(0, 255), $font, $sifre[2]);
         imagettftext($resim, $font_boyut, rand(-45, 45), $sM = $sMa + $sM, $uM, rand(0, 255), $font, $sifre[3]);
         imagettftext($resim, $font_boyut, rand(-45, 45), $sM = $sMa + $sM, $uM, rand(0, 255), $font, $sifre[4]);
         //ImageRectangle($resim, 0, 0, $genislik-1, $yukseklik-1, $kirmizi);
         imageline($resim, 0, $yukseklik / 2, $genislik, $yukseklik / 2, $kirmizi);
         imageline($resim, $genislik / 2, 0, $genislik / 2, $yukseklik, $kirmizi);
         header("Content-Type: image/png");
         ImagePng($resim);
         ImageDestroy($resim);
     }
     exit;
 }
Example #5
0
 function create($varDesc, $varValues)
 {
     Header("Content-type: image/png");
     $image = ImageCreate($this->imageWidth, $this->imageHeight);
     $bgcolor = ImageColorAllocate($image, $this->bgR, $this->bgG, $this->bgB);
     $white = ImageColorAllocate($image, 255, 255, 255);
     $black = ImageColorAllocate($image, 0, 0, 0);
     ImageFill($image, 0, 0, $bgcolor);
     $num = 0;
     foreach ($varDesc as $v) {
         $r = rand(0, 255);
         $g = rand(0, 255);
         $b = rand(0, 255);
         $sliceColors[$num] = ImageColorAllocate($image, $r, $g, $b);
         $num++;
     }
     // now $num has the number of elements
     // draw the box
     ImageLine($image, 0, 0, $this->imageWidth - 1, 0, $black);
     ImageLine($image, $this->imageWidth - 1, 0, $this->imageWidth - 1, $this->imageHeight - 1, $black);
     ImageLine($image, $this->imageWidth - 1, $this->imageHeight - 1, 0, $this->imageHeight - 1, $black);
     ImageLine($image, 0, $this->imageHeight - 1, 0, 0, $black);
     $total = 0;
     for ($x = 0; $x < $num; $x++) {
         $total += $varValues[$x];
     }
     // convert each slice into corresponding percentage of 360-degree circle
     for ($x = 0; $x < $num; $x++) {
         $angles[$x] = $varValues[$x] / $total * 360;
     }
     for ($x = 0; $x < $num; $x++) {
         // calculate and draw arc corresponding to each slice
         ImageArc($image, $this->imageWidth / 4, $this->imageHeight / 2, $this->imageWidth / 3, $this->imageHeight / 3, $angle, $angle + $angles[$x], $sliceColors[$x]);
         $angle = $angle + $angles[$x];
         $x1 = round($this->imageWidth / 4 + $this->imageWidth / 3 * cos($angle * pi() / 180) / 2);
         $y1 = round($this->imageHeight / 2 + $this->imageHeight / 3 * sin($angle * pi() / 180) / 2);
         // demarcate slice with another line
         ImageLine($image, $this->imageWidth / 4, $this->imageHeight / 2, $x1, $y1, $sliceColors[$x]);
     }
     // fill in the arcs
     $angle = 0;
     for ($x = 0; $x < $num; $x++) {
         $x1 = round($this->imageWidth / 4 + $this->imageWidth / 3 * cos(($angle + $angles[$x] / 2) * pi() / 180) / 4);
         $y1 = round($this->imageHeight / 2 + $this->imageHeight / 3 * sin(($angle + $angles[$x] / 2) * pi() / 180) / 4);
         ImageFill($image, $x1, $y1, $sliceColors[$x]);
         $angle = $angle + $angles[$x];
     }
     // put the desc strings
     ImageString($image, 5, $this->imageWidth / 2, 60, "Legend", $black);
     for ($x = 0; $x < $num; $x++) {
         $fl = sprintf("%.2f", $varValues[$x] * 100 / $total);
         $str = $varDesc[$x] . " (" . $fl . "%)";
         ImageString($image, 3, $this->imageWidth / 2, ($x + 5) * 20, $str, $sliceColors[$x]);
     }
     // put the title
     ImageString($image, 5, 20, 20, $this->title, $black);
     ImagePng($image);
     ImageDestroy($image);
 }
Example #6
0
function ResizeImage($Filename, $Thumbnail, $Size)
{
    $Path = pathinfo($Filename);
    $Extension = $Path['extension'];
    $ImageData = @GetImageSize($Filename);
    $Width = $ImageData[0];
    $Height = $ImageData[1];
    if ($Width >= $Height and $Width > $Size) {
        $NewWidth = $Size;
        $NewHeight = $Size / $Width * $Height;
    } elseif ($Height >= $Width and $Height > $Size) {
        $NewWidth = $Size / $Height * $Width;
        $NewHeight = $Size;
    } else {
        $NewWidth = $Width;
        $NewHeight = $Height;
    }
    $NewImage = @ImageCreateTrueColor($NewWidth, $NewHeight);
    if (preg_match('/^gif$/i', $Extension)) {
        $Image = @ImageCreateFromGif($Filename);
    } elseif (preg_match('/^png$/i', $Extension)) {
        $Image = @ImageCreateFromPng($Filename);
    } else {
        $Image = @ImageCreateFromJpeg($Filename);
    }
    if ($ImageData[2] == IMAGETYPE_GIF or $ImageData[2] == IMAGETYPE_PNG) {
        $TransIndex = imagecolortransparent($Image);
        // If we have a specific transparent color
        if ($TransIndex >= 0) {
            // Get the original image's transparent color's RGB values
            $TransColor = imagecolorsforindex($Image, $TransIndex);
            // Allocate the same color in the new image resource
            $TransIndex = imagecolorallocate($NewImage, $TransColor['red'], $TransColor['green'], $TransColor['blue']);
            // Completely fill the background of the new image with allocated color.
            imagefill($NewImage, 0, 0, $TransIndex);
            // Set the background color for new image to transparent
            imagecolortransparent($NewImage, $TransIndex);
        } elseif ($ImageData[2] == IMAGETYPE_PNG) {
            // Turn off transparency blending (temporarily)
            imagealphablending($NewImage, false);
            // Create a new transparent color for image
            $color = imagecolorallocatealpha($NewImage, 0, 0, 0, 127);
            // Completely fill the background of the new image with allocated color.
            imagefill($NewImage, 0, 0, $color);
            // Restore transparency blending
            imagesavealpha($NewImage, true);
        }
    }
    @ImageCopyResampled($NewImage, $Image, 0, 0, 0, 0, $NewWidth, $NewHeight, $Width, $Height);
    if (preg_match('/^gif$/i', $Extension)) {
        @ImageGif($NewImage, $Thumbnail);
    } elseif (preg_match('/^png$/i', $Extension)) {
        @ImagePng($NewImage, $Thumbnail);
    } else {
        @ImageJpeg($NewImage, $Thumbnail);
    }
    @chmod($Thumbnail, 0644);
}
 function avg_percent_fit_iskill($db_object, $common, $image, $user_id)
 {
     $user_table = $common->prefix_table("user_table");
     $model_factors_1 = $common->prefix_table("model_factors_1");
     $model_percent_fit = $common->prefix_table("models_percent_fit");
     $family_position = $common->prefix_table("family_position");
     $career_goals = $common->prefix_table("career_goals");
     $sql = "select position from {$user_table} where user_id='{$user_id}'";
     $sql_res = $db_object->get_a_line($sql);
     $pos_id = $sql_res[position];
     $user_pos = $common->get_chain_below($pos_id, $db_object, $twodarr);
     $count = 0;
     if (count($user_pos) == 0) {
         $heads = array(array("No employee", 3, "c"), array("under this admin", 3, "c"));
         $image = ImageCreate(150, 150);
         $white = ImageColorAllocate($image, 255, 255, 255);
         $black = ImageColorAllocate($image, 0, 0, 0);
         ImageString($image, $heads[0][1], 10, 0, $heads[0][0], $black);
         ImageString($image, $heads[1][1], 10, 15, $heads[1][0], $black);
         //ImageString($image,3,50,50,'heading',16);
         ImagePng($image);
     }
     for ($i = 0; $i < count($user_pos); $i++) {
         $pos = $user_pos[$i];
         $sql = "select user_id from {$user_table} where position='{$pos}'";
         $user_res = $db_object->get_a_line($sql);
         $user = $user_res[user_id];
         $sql = "select onelevel_up from {$career_goals} where user_id='{$user}'";
         $fly_res = $db_object->get_single_column($sql);
         if (count($fly_res) > 0) {
             $family_ids = @implode(",", $fly_res);
             $fly = "(" . $family_ids . ")";
             $sql = "select model_id from {$model_factors_1} where family in {$fly}";
             $model_arr = $db_object->get_single_column($sql);
             if (count($model_arr) > 0) {
                 $model_ids = @implode(",", $model_arr);
                 $models = "(" . $model_ids . ")";
                 $sql = "select avg(percent_fit) as percent from {$model_percent_fit} where model_id in {$models} \n\t\t\t\t\t\n\t\t\t\t\tand user_id='{$user}'";
                 $percent_arr = $db_object->get_a_line($sql);
                 $total_percent += $percent_arr[0];
                 $count++;
             }
         }
     }
     if ($count >= 1) {
         $percent = $total_percent / $count;
     } else {
         $percent = 0;
     }
     $total = 100;
     $heads = array(array("One Level Up Fit", 3, "c"));
     $array = array($percent, $total);
     $vals = $image->return_Array($array);
     $image->init(150, 150, $vals);
     $image->draw_heading($heads);
     $image->set_legend_percent();
     $image->display($filename);
 }
Example #8
0
function png($panels, $name)
{
    if (count($panels) > 0) {
        echo "Les images générées vont être enregistrées au format PNG.\n";
    }
    $i = 0;
    while (isset($panels[$i])) {
        ImagePng($panels[$i], $name . $i . ".png");
        $i++;
    }
}
Example #9
0
 public static function png($frame, $filename = false, $pixelPerPoint = 4, $outerFrame = 4, $saveandprint = FALSE)
 {
     $image = self::image($frame, $pixelPerPoint, $outerFrame, $saveandprint);
     if ($filename === false) {
         Header("Content-type: image/png");
         ImagePng($image);
     } else {
         ImagePng($image, $filename);
     }
     ImageDestroy($image);
 }
Example #10
0
 public function FlushObject()
 {
     if ($this->mStyle & BCS_BORDER) {
         $this->DrawBorder();
     }
     if ($this->mStyle & BCS_IMAGE_PNG) {
         ImagePng($this->mImg);
     } else {
         if ($this->mStyle & BCS_IMAGE_JPEG) {
             ImageJpeg($this->mImg);
         }
     }
 }
 /**
  * Override the parent's go method because there is no view manager here--we're outputting the image directly.
  */
 public function go()
 {
     $config = Config::getInstance();
     $this->setContentType('image/png');
     $random_num = rand(1000, 99999);
     $_SESSION['ckey'] = md5($random_num);
     $img = rand(1, 4);
     $img_handle = imageCreateFromPNG($config->getValue('source_root_path') . "webapp/assets/img/captcha/bg" . $img . ".PNG");
     $color = ImageColorAllocate($img_handle, 0, 0, 0);
     ImageString($img_handle, 5, 20, 13, $random_num, $color);
     ImagePng($img_handle);
     ImageDestroy($img_handle);
 }
 function avg_percent_fit_iskill($db_object, $common, $image, $user_id)
 {
     $user_table = $common->prefix_table("user_table");
     $model_factors_1 = $common->prefix_table("model_factors_1");
     $model_percent_fit = $common->prefix_table("models_percent_fit");
     $family_position = $common->prefix_table("family_position");
     $users = $common->return_direct_reports($db_object, $user_id);
     for ($i = 0; $i < count($users); $i++) {
         $user = $users[$i];
         $sql = "select position from {$user_table} where user_id='{$user}'";
         $pos_res = $db_object->get_a_line($sql);
         $pos = $pos_res[position];
         $sql = "select family_id from {$family_position} where position_id='{$pos}'";
         $fly_res = $db_object->get_single_column($sql);
         if (count($fly_res) > 0) {
             $family_ids = @implode(",", $fly_res);
             $fly = "(" . $family_ids . ")";
             $sql = "select model_id from {$model_factors_1} where family in {$fly}";
             $model_arr = $db_object->get_single_column($sql);
             if (count($model_arr) > 0) {
                 $model_ids = @implode(",", $model_arr);
                 $models = "(" . $model_ids . ")";
                 $sql = "select avg(percent_fit) as percent from {$model_percent_fit} where model_id in {$models} \n\t\t\t\t\t\n\t\t\t\t\tand user_id='{$user}' and skill_type='i'";
                 $percent_arr = $db_object->get_a_line($sql);
                 $total_percent += $percent_arr[0];
             }
         }
     }
     if (count($users) >= 1) {
         $percent = $total_percent / count($users);
         $total = 100;
         $heads = array(array("IP Percentage Fit", 3, "c"));
         $array = array($percent, $total);
         $vals = $image->return_Array($array);
         $image->init(150, 150, $vals);
         $image->draw_heading($heads);
         $image->set_legend_percent();
         $image->display($filename);
     } else {
         $heads = array(array("No employee", 3, "c"), array("under this boss", 3, "c"));
         $image = ImageCreate(150, 150);
         $white = ImageColorAllocate($image, 255, 255, 255);
         $black = ImageColorAllocate($image, 0, 0, 0);
         ImageString($image, $heads[0][1], 10, 0, $heads[0][0], $black);
         ImageString($image, $heads[1][1], 10, 15, $heads[1][0], $black);
         //ImageString($image,3,50,50,'heading',16);
         ImagePng($image);
     }
 }
Example #13
0
 public function create_code($value, $img_name)
 {
     $value = $_GET['url'];
     //二维码内容
     $QR = $this->path . $img_name . '.png';
     if (!file_exists($QR)) {
         //生成二维码图片
         QRcode::png($value, $QR, $this->errorCorrectionLevel, $this->matrixPointSize, 2);
     }
     if ($this->start) {
         $QR = $this->logo_code($QR);
     }
     Header("Content-type: image/png");
     ImagePng($QR);
 }
Example #14
0
 /**
  * @param $frame
  * @param bool $filename
  * @param int $pixelPerPoint
  * @param int $outerFrame
  * @param bool $saveAndPrint
  * @param RgbColor $fgColor
  * @param RgbColor $bgColor
  */
 public static function png($frame, $filename = false, $pixelPerPoint = 4, $outerFrame = 4, $saveAndPrint = false, RgbColor $fgColor = null, RgbColor $bgColor = null)
 {
     $image = static::image($frame, $pixelPerPoint, $outerFrame, $fgColor, $bgColor);
     if ($filename === false) {
         Header("Content-type: image/png");
         ImagePng($image);
     } else {
         ImagePng($image, $filename);
         if ($saveAndPrint === true) {
             header("Content-type: image/png");
             ImagePng($image);
         }
     }
     ImageDestroy($image);
 }
Example #15
0
function kleeja_cpatcha_image()
{
    //Let's generate a totally random string using md5
    $md5_hash = md5(rand(0, 999));
    //I think the bad things in captcha is two things, O and 0 , so let's remove zero.
    $security_code = str_replace('0', '', $md5_hash);
    //We don't need a 32 character long string so we trim it down to 5
    $security_code = substr($security_code, 15, 5);
    //Set the session to store the security code
    $_SESSION["klj_sec_code"] = $security_code;
    //Set the image width and height
    $width = 150;
    $height = 25;
    //Create the image resource
    $image = ImageCreate($width, $height);
    //We are making three colors, white, black and gray
    $white = ImageColorAllocate($image, 255, 255, 255);
    $black = ImageColorAllocate($image, rand(0, 100), 0, rand(0, 50));
    $grey = ImageColorAllocate($image, 204, 204, 204);
    //Make the background black
    ImageFill($image, 0, 0, $black);
    //options
    $x = 10;
    $y = 14;
    $angle = rand(-7, -10);
    //Add randomly generated string in white to the image
    if (function_exists('imagettftext')) {
        //
        // We figure a bug that happens when you add font name without './' before it ..
        // he search in the Linux fonts cache , but when you add './' he will know it's our font.
        //
        imagettftext($image, 16, $angle, rand(50, $x), $y + rand(1, 3), $white, './arial.ttf', $security_code);
    } else {
        imagestring($image, imageloadfont('arial.gdf'), $x + rand(10, 15), $y - rand(10, 15), $security_code, $white);
    }
    //kleeja !
    imagestring($image, 1, $width - 35, $height - 10, 'Kleeja', ImageColorAllocate($image, 200, 200, 200));
    //Throw in some lines to make it a little bit harder for any bots to break
    ImageRectangle($image, 0, 0, $width - 1, $height - 1, $grey);
    imageline($image, 0, $height / 2, $width, $height / 2, $grey);
    imageline($image, $width / 2, 0, $width / 2, $height, $grey);
    //Tell the browser what kind of file is come in
    header("Content-Type: image/png");
    //Output the newly created image in jpeg format
    ImagePng($image);
    //Free up resources
    ImageDestroy($image);
}
Example #16
0
function ShowImageHeader($ImageHandle)
{
    if (ImageTypes() & IMG_PNG) {
        Header("Content-type: image/png");
        ImagePng($ImageHandle);
    } elseif (ImageTypes() & IMG_GIF) {
        Header("Content-type: image/gif");
        ImageGif($ImageHandle);
    } elseif (ImageTypes() & IMG_JPEG) {
        Header("Content-type: image/jpeg");
        ImageJpeg($ImageHandle, "", 0.5);
    } else {
        die("No images support");
    }
    ImageDestroy($ImageHandle);
}
Example #17
0
 public static function png($frame, $filename = false, $pixelPerPoint = 4, $outerFrame = 4, $saveandprint = FALSE, $back_color, $fore_color)
 {
     $image = self::image($frame, $pixelPerPoint, $outerFrame, $back_color, $fore_color);
     if ($filename === false) {
         Header("Content-type: image/gif");
         ImagePng($image);
     } else {
         if ($saveandprint === TRUE) {
             ImagePng($image, $filename);
             header("Content-type: image/gif");
             ImagePng($image);
         } else {
             ImagePng($image, $filename);
         }
     }
     ImageDestroy($image);
 }
Example #18
0
 public static function png($frame, $filename = false, $pixelPerPoint = 4, $outerFrame = 4, $saveandprint = FALSE)
 {
     $image = self::image($frame, $pixelPerPoint, $outerFrame);
     imagetruecolortopalette($image, false, 255);
     if ($filename === false) {
         Header("Content-type: image/png");
         ImagePng($image);
     } else {
         if ($saveandprint === TRUE) {
             ImagePng($image, $filename);
             header("Content-type: image/png");
             ImagePng($image);
         } else {
             ImagePng($image, $filename);
         }
     }
     ImageDestroy($image);
 }
Example #19
0
 public function guvenlikKodu()
 {
     $kod = substr(md5(rand(0, 999999999999.0)), -6);
     if ($kod) {
         $this->session->set_userdata("guvKod", $kod);
         $width = 100;
         $height = 30;
         $resim = ImageCreate($width, $height);
         $beyaz = ImageColorAllocate($resim, 255, 255, 255);
         $rand = ImageColorAllocate($resim, rand(0, 255), rand(0, 255), rand(0, 255));
         ImageFill($resim, 0, 0, $rand);
         ImageString($resim, 5, 24, 7, $this->session->userdata("guvKod"), $beyaz);
         ImageLine($resim, 100, 19, 0, 19, $beyaz);
         header("Content,type:image/png");
         ImagePng($resim);
         ImageDestroy($resim);
         $this->session->set_userdata("guvKod2", $this->session->userdata("guvKod"));
     }
 }
 /**
  * Override the parent's go method because there is no view manager here--we're outputting the image directly.
  */
 public function go()
 {
     $config = Config::getInstance();
     $random_num = rand(1000, 99999);
     $_SESSION['ckey'] = md5($random_num);
     $img = rand(1, 4);
     Utils::defineConstants();
     $captcha_bg_image_path = THINKUP_WEBAPP_PATH . "assets/img/captcha/bg" . $img . ".PNG";
     $img_handle = imageCreateFromPNG($captcha_bg_image_path);
     if ($img_handle === false) {
         echo 'CAPTCHA image could not be created from ' . $captcha_bg_image_path;
     } else {
         $this->setContentType('image/png');
         $color = ImageColorAllocate($img_handle, 0, 0, 0);
         ImageString($img_handle, 5, 20, 13, $random_num, $color);
         ImagePng($img_handle);
         ImageDestroy($img_handle);
     }
 }
Example #21
0
 public static function buildCache()
 {
     QRtools::markTime('before_build_cache');
     $mask = new QRmask();
     for ($a = 1; $a <= Constants::QRSPEC_VERSION_MAX; $a++) {
         $frame = QRspec::newFrame($a);
         if (Constants::QR_IMAGE) {
             $fileName = Constants::QR_CACHE_DIR . 'frame_' . $a . '.png';
             $image = QRimage::image(self::binarize($frame), $fileName, 1, 0);
             ImagePng($image, $filename);
         }
         $width = count($frame);
         $bitMask = array_fill(0, $width, array_fill(0, $width, 0));
         for ($maskNo = 0; $maskNo < 8; $maskNo++) {
             $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true);
         }
     }
     QRtools::markTime('after_build_cache');
 }
Example #22
0
 /**
  * Convierte un texto a imagen
  * @param string $texto
  */
 public function executeText2img(sfWebRequest $request)
 {
     //fuente por defecto
     $this->font = 2;
     //obtengo el texto
     $texto = utf8_decode($request->getParameter('texto', 'null'));
     //seteo el header
     header("Content-type: image/png");
     // calculo el alto
     $alto = strlen($texto) * imagefontwidth($this->font) + imagefontwidth($this->font);
     $img_handle = imagecreatetruecolor(imagefontheight($this->font), $alto) or die("Cannot Create image");
     // ImageColorAllocate (image, red, green, blue)
     $back_color = ImageColorAllocate($img_handle, 255, 255, 255);
     $txt_color = ImageColorAllocate($img_handle, 0, 0, 0);
     ImageFill($img_handle, 0, 0, $back_color);
     ImageStringUp($img_handle, $this->font, 0, $alto - imagefontwidth($this->font) / 2, $texto, $txt_color);
     ImagePng($img_handle);
     ImageDestroy($img_handle);
     return sfView::NONE;
 }
Example #23
0
 function __construct($debugMode)
 {
     if (!$debugMode) {
         header("Content-type: image/png");
     } else {
         echo "constructing!";
     }
     $this->mapCities = array("Liverpool" => array("type" => HEXTYPE_RAILWAY_TOWN, "position" => "0,1", "color" => "255/0/0", "railway" => "L&Y"), "Bristol" => array("type" => HEXTYPE_RAILWAY_TOWN, "position" => "0,12", "color" => "255/0/0", "railway" => "GWR"), "Stoke" => array("type" => HEXTYPE_RAILWAY_TOWN, "position" => "2,4", "color" => "255/0/0", "railway" => "LNWR"), "Southhampton" => array("type" => HEXTYPE_RAILWAY_TOWN, "position" => "5,15", "color" => "255/0/0", "railway" => "LSWR"), "York" => array("type" => HEXTYPE_RAILWAY_TOWN, "position" => "8,0", "color" => "255/0/0", "railway" => "NER"), "Norwich" => array("type" => HEXTYPE_RAILWAY_TOWN, "position" => "14,7", "color" => "255/0/0", "railway" => "GER"), "Dover" => array("type" => HEXTYPE_RAILWAY_TOWN, "position" => "15,14", "color" => "255/0/0", "railway" => "SER"), "Salisbury" => array("type" => HEXTYPE_TOWN, "position" => "3,12"), "Leeds" => array("type" => HEXTYPE_TOWN, "position" => "4,0"), "Derby" => array("type" => HEXTYPE_TOWN, "position" => "5,4"), "Oxford" => array("type" => HEXTYPE_TOWN, "position" => "5,10"), "Ragby" => array("type" => HEXTYPE_TOWN, "position" => "6,7"), "Avesbury" => array("type" => HEXTYPE_TOWN, "position" => "8,11"), "Lincoln" => array("type" => HEXTYPE_TOWN, "position" => "9,2"), "Peterborough" => array("type" => HEXTYPE_TOWN, "position" => "10,7"), "Ashford" => array("type" => HEXTYPE_TOWN, "position" => "12,14"), "Gloucester" => array("type" => HEXTYPE_CITY, "position" => "2,10", "color" => "252/126/127"), "Hertford" => array("type" => HEXTYPE_CITY, "position" => "11,10", "color" => "141/72/53"), "Sheffield" => array("type" => HEXTYPE_CITY, "position" => "6,2", "color" => "121/124/205"), "Brighton" => array("type" => HEXTYPE_CITY, "position" => "10,16", "color" => "155/112/175"), "Guildford" => array("type" => HEXTYPE_CITY, "position" => "8,14", "color" => "187/189/45"), "Nottingham" => array("type" => HEXTYPE_CITY, "position" => "8,5", "color" => "104/154/156"), "Cambridge" => array("type" => HEXTYPE_CITY, "position" => "12,9", "color" => "122/177/113"), "London" => array("type" => HEXTYPE_CITY, "position" => "10,13", "color" => "230/79/124"), "Reading" => array("type" => HEXTYPE_CITY, "position" => "6,13", "color" => "169/113/48"), "Birmingham" => array("type" => HEXTYPE_CITY, "position" => "3,6", "color" => "143/122/115"), "Manchester" => array("type" => HEXTYPE_CITY, "position" => "3,1", "color" => "236/226/244"), "Northampton" => array("type" => HEXTYPE_CITY, "position" => "7,8", "color" => "129/149/43"));
     if (false) {
         $handle = ImageCreate(1600, 1700) or die("Cannot Create image");
         ImageColorAllocate($handle, 0, 255, 255);
     } else {
         $handle = imagecreatefromjpeg("england.jpg");
     }
     // $txt_color = ImageColorAllocate ($handle, 255, 0, 0);
     // ImageString ($handle, 5, 5, 18, "HELLO WORLD", $txt_color);
     $this->drawGrid($handle);
     if (!$debugMode) {
         ImagePng($handle);
     }
 }
 public function qrcimg()
 {
     $value = I('content');
     // 二维码内容
     if (!$value) {
         die("操作非法");
     }
     Vendor('phpqrc.Qrcutils');
     $logo = './images/icon.png';
     // 准备好的logo图片
     $QR = './images/qrcode.png';
     // 已经生成的原始二维码图
     $errorCorrectionLevel = I('qrc_level', 'H');
     // 容错级别
     $matrixPointSize = I('qrc_size', 10);
     // 生成图片大小
     //创建二维码
     $img = \Qrctils::createImg($value, $errorCorrectionLevel, $matrixPointSize, $logo, $QR);
     // 输出图片
     Header("Content-type: image/png");
     ImagePng($img);
 }
Example #25
0
 public static function make()
 {
     $sessionvar = 'vdcode';
     //Session变量名称
     $width = 150;
     //图像宽度
     $height = 20;
     //图像高度
     $ans = mt_rand(0, 9);
     $p1 = mt_rand(1, 9);
     if ($p1 <= $ans) {
         $p2 = $ans - $p1;
         $operator = '+';
     } else {
         $p2 = $p1 - $ans;
         $operator = '-';
     }
     $code = array();
     $code[] = $p1;
     $code[] = $operator;
     $code[] = $p2;
     $code[] = '=';
     $code[] = $ans;
     $_SESSION[$sessionvar] = $ans;
     $img = ImageCreate($width, $height);
     ImageColorAllocate($img, mt_rand(230, 250), mt_rand(230, 250), mt_rand(230, 250));
     $color = ImageColorAllocate($img, 0, 0, 0);
     $offset = 0;
     foreach ($code as $char) {
         $offset += 20;
         $txtcolor = ImageColorAllocate($img, mt_rand(0, 255), mt_rand(0, 150), mt_rand(0, 255));
         ImageChar($img, mt_rand(3, 5), $offset, mt_rand(3, 5), $char, $txtcolor);
     }
     for ($i = 0; $i < 100; $i++) {
         $pxcolor = ImageColorAllocate($img, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         ImageSetPixel($img, mt_rand(0, $width), mt_rand(0, $height), $pxcolor);
     }
     return ImagePng($img);
 }
Example #26
0
function abatly_captcha()
{
    $md5_hash = md5(rand(0, 999));
    $security_code = str_replace('0', '', $md5_hash);
    $security_code = substr($security_code, 15, 5);
    $_SESSION["security_code"] = $security_code;
    $width = 128;
    $height = 40;
    $image = ImageCreate($width, $height);
    $white = ImageColorAllocate($image, 255, 255, 255);
    $black = ImageColorAllocate($image, rand(0, 100), 0, rand(0, 50));
    $grey = ImageColorAllocate($image, 204, 204, 204);
    $red = imagecolorallocatealpha($image, 255, 0, 0, 75);
    $green = imagecolorallocatealpha($image, 0, 255, 0, 75);
    $blue = imagecolorallocatealpha($image, 0, 0, 255, 75);
    imagefilledrectangle($image, 0, 0, $width, $height, $white);
    imagefilledellipse($image, ceil(rand(5, 145)), ceil(rand(0, 35)), 30, 30, $red);
    imagefilledellipse($image, ceil(rand(5, 145)), ceil(rand(0, 35)), 30, 30, $green);
    imagefilledellipse($image, ceil(rand(5, 145)), ceil(rand(0, 35)), 30, 30, $blue);
    imagefilledrectangle($image, 0, 0, $width, 0, $black);
    imagefilledrectangle($image, $width - 1, 0, $width - 1, $height - 1, $black);
    imagefilledrectangle($image, 0, 0, 0, $height - 1, $black);
    imagefilledrectangle($image, 0, $height - 1, $width, $height - 1, $black);
    ImageFill($image, 0, 0, $black);
    $x = 20;
    $y = 24;
    $angle = rand(-7, -10);
    if (function_exists('imagettftext')) {
        imagettftext($image, 20, $angle, rand(20, $x), $y + rand(1, 3), $black, 'arial.ttf', $security_code);
    } else {
        imagestring($image, imageloadfont('arial.gdf'), $x + rand(10, 15), $y - rand(10, 15), $security_code, $white);
    }
    ImageRectangle($image, 0, 0, $width - 1, $height - 1, $black);
    imageline($image, $width / 2, 0, $width / 2, $height, $black);
    header("Content-Type: image/png");
    ImagePng($image);
    ImageDestroy($image);
}
Example #27
0
function blah($cstr)
{
    $old_security_string = $cstr;
    $security_string = "";
    for ($i = 0; $i <= strlen($old_security_string) - 1; $i++) {
        $str = substr($old_security_string, $i, 1);
        if ($i % 2 == 0) {
            $str = strtoupper($str);
        }
        $security_string = $security_string . $str . ' ';
    }
    $_SESSION["captchaStr"] = $old_security_string;
    $width = 100;
    $height = 30;
    $image = ImageCreate($width, $height);
    $white = ImageColorAllocate($image, 255, 255, 255);
    $black = ImageColorAllocate($image, 0, 0, 0);
    $grey = ImageColorAllocate($image, 120, 120, 120);
    $red = ImageColorAllocate($image, 132, 12, 4);
    ImageFill($image, 5, 5, $grey);
    $font = 8;
    imagestring($image, 15, 12, 8, $security_string, $white);
    //ImageString($image, $font, 12, 3, $security_string, $white);
    ImageRectangle($image, 0, 0, $width - 1, $height - 1, $black);
    /*
    	$line = imagecolorallocate($image,233,239,239); 
    
    	imageline($image,0,0,39,29,$line);
    	imageline($image,60,0,40,29,$line);
    	imageline($image,40,0,64,29,$line);
    	imageline($image,80,0,94,29,$line);
    */
    header("Content-Type: image/png");
    ImagePng($image);
    ImageDestroy($image);
}
Example #28
0
 /**
  * Outputs the image to the screen, or saves to $name if supplied.  Quality of JPEG images can be controlled with the $quality variable
  *
  * @param int $quality
  * @param string $name
  */
 function show($quality = 100, $name = '')
 {
     switch ($this->format) {
         case 'GIF':
             if ($name != '') {
                 @ImageGif($this->newImage, $name) or $this->error = true;
             } else {
                 header('Content-type: image/gif');
                 ImageGif($this->newImage);
             }
             break;
         case 'JPG':
             if ($name != '') {
                 @ImageJpeg($this->newImage, $name, $quality) or $this->error = true;
             } else {
                 header('Content-type: image/jpeg');
                 ImageJpeg($this->newImage, NULL, $quality);
             }
             break;
         case 'PNG':
             if ($name != '') {
                 @ImagePng($this->newImage, $name) or $this->error = true;
             } else {
                 header('Content-type: image/png');
                 ImagePng($this->newImage);
             }
             break;
     }
 }
Example #29
0
 function PrintImage()
 {
     // Browser cache stuff submitted by Thiemo Nagel
     if (!$this->browser_cache && !$this->is_inline) {
         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
         header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT');
         header('Cache-Control: no-cache, must-revalidate');
         header('Pragma: no-cache');
     }
     switch ($this->file_format) {
         case 'png':
             if (!$this->is_inline) {
                 Header('Content-type: image/png');
             }
             if ($this->is_inline && $this->output_file != '') {
                 ImagePng($this->img, $this->output_file);
             } else {
                 ImagePng($this->img);
             }
             break;
         case 'jpg':
             if (!$this->is_inline) {
                 Header('Content-type: image/jpeg');
             }
             if ($this->is_inline && $this->output_file != '') {
                 ImageJPEG($this->img, $this->output_file);
             } else {
                 ImageJPEG($this->img);
             }
             break;
         case 'gif':
             if (!$this->is_inline) {
                 Header('Content-type: image/gif');
             }
             if ($this->is_inline && $this->output_file != '') {
                 ImageGIF($this->img, $this->output_file);
             } else {
                 ImageGIF($this->img);
             }
             break;
         case 'wbmp':
             // wireless bitmap, 2 bit.
             if (!$this->is_inline) {
                 Header('Content-type: image/wbmp');
             }
             if ($this->is_inline && $this->output_file != '') {
                 ImageWBMP($this->img, $this->output_file);
             } else {
                 ImageWBMP($this->img);
             }
             break;
         default:
             $this->PrintError('PrintImage(): Please select an image type!');
             break;
     }
     return TRUE;
 }
Example #30
0
 public function genBarCode($code_id)
 {
     $text = $code_id;
     $font_size = 50;
     $height = 80;
     $width = 100;
     $im = ImageCreate($width, $height);
     $grey = ImageColorAllocate($im, 230, 230, 230);
     $black = ImageColorAllocate($im, 0, 0, 0);
     $text_bbox = ImageTTFBBox($font_size, 0, "font/FRE3OF9X.TTF", $text);
     $image_centerx = $width / 2;
     $image_centery = $height / 2;
     $text_x = $image_centerx - round($text_bbox[4] / 2);
     $text_y = $image_centery;
     ImageTTFText($im, $font_size, 0, $text_x, $text_y, $black, "font/FRE3OF9X.TTF", $text);
     ImagePng($im, "barcode/bc_{$code_id}.png");
     ImageDestroy($im);
     //echo "<img src=image.png>";
     /*
               $str="1234";
               putenv('GDFONTPATH=' . realpath('.'));
               $font = "FRE3OF9X.TTF";
               $image = imagecreate(100,30);
               $bg = imagecolorallocate($image,100,220,220);
               $black = imagecolorallocate($image, 0, 0, 0);
               imagettftext($image,28,0,2,25,$black,$font,$str);
               header("Content-type:image/png");
               imagepng($image);
               imagedestroy($image); */
 }