예제 #1
0
파일: picgen.php 프로젝트: ramant15/ektimo
     if (isset($_SESSION['cptch'])) {
         $_GET['image'] = $_SESSION['cptch'];
     } else {
         $_SESSION['cptch'] = rand(10, 99) . substr($letters, rand(1, 20), 1) . substr($letters, rand(1, 20), 1) . rand(10, 99);
         $_SESSION['c_s_id'] = md5($_SESSION['cptch']);
     }
 }
 $text = $_GET['image'];
 $usedfont = $_GET['font'];
 $fontsize = $_GET['size'];
 $tmp_fontcolor = $_GET['color'];
 $bgcolor = $_GET['rgb_bg'];
 header("Content-Type: image/png");
 $font = '../fonts/' . $usedfont . '.ttf';
 // Calc the text size
 $box = ImageTTFbbox($fontsize, 0, $font, $text);
 // Calc some props for the image
 $width = $box[2] - $box[0];
 $height = $box[1] - $box[7];
 // 10 px empty space on each side
 $imagewidth = $width + 20;
 $imageheight = $height + 5;
 // Create the image
 $pic = ImageCreate($imagewidth, $imageheight);
 // Set the colors
 // Backgroundcolor
 $rgb = explode(',', $bgcolor);
 $bgcolor = ImageColorAllocate($pic, $rgb[0], $rgb[1], $rgb[2]);
 // Fontcolor
 switch ($tmp_fontcolor) {
     case "red":
예제 #2
0
 function create_image()
 {
     // build a PNG image from the generated codestring
     header('Content-type: image/png');
     $box = ImageTTFbbox($this->fontsize, 0, $this->fontfile, $this->article);
     $src_img = ImageCreate($box[2] + 11, abs($box[7] - $box[1]) + 6);
     $black = ImageColorAllocate($src_img, 0x0, 0x0, 0x0);
     $white = ImageColorAllocate($src_img, 0xff, 0xff, 0xff);
     ImageFill($src_img, 0, 0, $white);
     ImageColorTransparent($src_img, $white);
     ImageTTFText($src_img, $this->fontsize, 0, 3, abs($box[7]), $black, $this->fontfile, $this->article);
     ImagePNG($src_img);
     ImageDestroy($src_img);
 }