Exemplo n.º 1
0
 private function createnewpicture()
 {
     $local = $this->path_two . $this->file['name'];
     move_uploaded_file($this->file['tmp_name'], $local);
     $filename = $this->file['tmp_name'] . "/" . $this->file['name'];
     $this->location = $this->path . "/" . $this->file['name'];
     switch ($this->file['type']) {
         case 'image/jpeg':
             $src = imagecreatefromjpeg($local);
             break;
         case 'image/png':
             $src = imagecreatefrompng($local);
             break;
         case 'image/gif':
             $src = imagecreatefromgif($local);
             break;
         default:
             break;
     }
     $sx = imagesx($src);
     $sy = imagesy($src);
     $new_image = imagecreatetruecolor($this->newwidth, $this->newheight);
     if (imagecopyresized($new_image, $src, 0, 0, 0, 0, $this->newwidth, $this->newheight, $sx, $sy)) {
         if (ImageJpeg($new_image, $this->location) || Imagegif($new_image, $this->location) || Imagepng($new_image, $this->location)) {
             //imagejpeg($this->location);
             return true;
         }
     } else {
         return false;
     }
 }
 function display($db_object, $common, $user_id, $default, $error_msg, $learning, $post_var)
 {
     $width = 340;
     $height = 220;
     //	$labelfont = '2';
     $labeltitlefont = '3';
     $image = ImageCreate($width, $height);
     while (list($kk, $vv) = @each($post_var)) {
         ${$kk} = $vv;
     }
     /*
     $to_date=2004-01-02;
     $from_date=2004-01-02;
     $avg_rater=50.23;
     */
     $bgcolor = ImageColorAllocate($image, 0xffffff, 0xffffff, 0xffffff);
     $border = ImageColorAllocate($image, 0x0, 0x0, 0x0);
     $border1 = ImageColorAllocate($image, 0xcccccc, 0x0, 0x0);
     //$border2 = ImageColorAllocate($image,0x000000, 0xcccccc, 0x000000);
     ImageRectangle($image, 40, 20, 240, 160, $border);
     ImageString($image, $labelfont, 15, 20, "100%", $border);
     ImageString($image, $labelfont, 20, 55, "75%", $border);
     ImageString($image, $labelfont, 20, 90, "50%", $border);
     ImageString($image, $labelfont, 20, 125, "25%", $border);
     ImageString($image, $labelfont, 20, 155, "0%", $border);
     $fdate = $learning->changedate_display($from_date);
     $tdate = $learning->changedate_display($to_date);
     $days = $error_msg['cDays'] . " {$fdate} " . $error_msg['cTo'] . " {$tdate} ";
     $avg_rt = @explode(",", $avg_rater);
     $id = @explode(",", $ids);
     for ($i = 0; $i < count($avg_rt); $i++) {
         $p1 = rand(0, 200);
         $p2 = rand(30, 250);
         $p3 = rand(100, 250);
         $color = imagecolorallocate($image, $p1, $p2, $p3);
         $avg = $avg_rt[$i];
         $avg_comp = 160 - 140 / 100 * $avg;
         $avg = round($avg, 2);
         $rid = $id[$i];
         $rname = $common->name_display($db_object, $rid);
         ImageStringUp($image, $labeltitlefont, 5, 110, $error_msg['cResults'], $border);
         ImageString($image, $labeltitlefont, 245, 20, $error_msg['cCommitment'], $border);
         ImageString($image, $labeltitlefont, 50, 170, "{$days}", $border);
         //ImageString($image, $labeltitlefont, 50,180, "$rname", $color);
         ImageLine($image, 240, 20, 40, 160, $border1);
         //COMMITMENT LINE
         ImageLine($image, 240, $avg_comp, 40, 160, $color);
         //AVERAGE COMPLETION
         header("Content-type: image/png");
         // or "Content-type: image/png"
         Imagepng($image);
         // or imagepng($image)
     }
     ImageDestroy($image);
 }
Exemplo n.º 3
0
 public function setimg($img, $age, $gender, $score, $infos, $res, $skin, $huitou, $target, $types)
 {
     $dst = "/mnt/meilimei/m/upload/mojokbg.png";
     //得到原始图片信息
     $dst_im = imagecreatefrompng($dst);
     $dst_info = getimagesize($dst);
     //水印图像
     $src = "/mnt/meilimei/m/upload/mojokbg2.png";
     $src_im = imagecreatefrompng($src);
     $src_info = getimagesize($src);
     if ($types == 'image/png') {
         $im = imagecreatefrompng($img);
         //imagecreatefrompng
     } elseif ($types == 'image/jpeg') {
         $im = imagecreatefromjpeg($img);
     } elseif ($types == 'image/gif') {
         $im = imagecreatefromgif($img);
     } elseif ($types == 'image/bmp') {
         $im = imagecreatefromwbmp($img);
     }
     $im_src = getimagesize($img);
     $temp_img = imagecreatetruecolor(320, 480);
     //创建画布
     //$im=create($src);
     imagecopyresampled($temp_img, $im, 0, 0, 0, 0, 226, 313, $im_src[0], $im_src[1]);
     //人脸
     $alpha = 100;
     imagecopy($dst_im, $temp_img, 48, 75, 0, 0, 226, 313);
     //后人脸
     imagecopy($dst_im, $src_im, 45, 72, 0, 0, 237, 323);
     //背景
     //$im = imagecreate(400 , 300);
     $gray = ImageColorAllocate($dst_im, 255, 255, 255);
     $pink = ImageColorAllocate($dst_im, 246, 109, 152);
     $fontfilebold = "/mnt/meilimei/m/upload/msyhbd.ttf";
     $fontfile = "/mnt/meilimei/m/upload/msyh.ttf";
     $str = iconv('GB2312', 'UTF-8', $huitou . '%');
     $str1 = $infos;
     $str2 = iconv('GB2312', 'UTF-8', $skin);
     $str3 = iconv('GB2312', 'UTF-8', $score);
     $str4 = iconv('GB2312', 'UTF-8', $age);
     ImageTTFText($dst_im, 22, 0, 175, 40, $gray, $fontfilebold, $str);
     ImageTTFText($dst_im, 11, 0, 50, 65, $gray, $fontfile, $str1);
     ImageTTFText($dst_im, 19, 0, 67, 225, $pink, $fontfilebold, $str2);
     ImageTTFText($dst_im, 19, 0, 67, 273, $pink, $fontfilebold, $str3);
     ImageTTFText($dst_im, 19, 0, 67, 320, $pink, $fontfilebold, $str4);
     imagesavealpha($src_im, true);
     imagesavealpha($dst_im, true);
     Imagepng($dst_im, "/mnt/meilimei/m/upload/webmojing/" . date('Y') . '/' . date('m') . '/' . $target . ".jpg");
     return ImageDestroy($dst_im);
 }
Exemplo n.º 4
0
function img($text)
{
    $img_height = 50;
    $img_width = 18;
    $img = imagecreate($img_height, $img_width);
    ImageColorAllocate($img, 255, 255, 255);
    $black = ImageColorAllocate($img, 0, 0, 0);
    for ($i = 0; $i < 10; $i++) {
        ImageString($img, 1, mt_rand(1, $img_height), mt_rand(0, $img_width), "Q", imageColorAllocate($img, mt_rand(200, 255), mt_rand(200, 255), mt_rand(200, 255)));
    }
    ImageRectangle($img, 0, 0, $img_height - 1, $img_width - 1, $black);
    //
    Imagestring($img, 5, 5, 2, $text, imageColorAllocate($img, mt_rand(0, 100), mt_rand(0, 150), mt_rand(0, 200)));
    Imagepng($img);
    ImageDestroy($img);
}
Exemplo n.º 5
0
 function display($db_object, $common, $user_id, $default, $error_msg, $learning, $post_var)
 {
     $width = 340;
     $height = 220;
     //	$labelfont = '2';
     $labeltitlefont = '3';
     $image = ImageCreate($width, $height);
     while (list($kk, $vv) = @each($post_var)) {
         ${$kk} = $vv;
     }
     $bgcolor = ImageColorAllocate($image, 0xffffff, 0xffffff, 0xffffff);
     $border = ImageColorAllocate($image, 0x0, 0x0, 0x0);
     $border1 = ImageColorAllocate($image, 0xcccccc, 0x0, 0x0);
     $border2 = ImageColorAllocate($image, 0x0, 0xcccccc, 0x0);
     ImageRectangle($image, 40, 20, 240, 160, $border);
     ImageString($image, $labelfont, 15, 20, "100%", $border);
     ImageString($image, $labelfont, 20, 55, "75%", $border);
     ImageString($image, $labelfont, 20, 90, "50%", $border);
     ImageString($image, $labelfont, 20, 125, "25%", $border);
     ImageString($image, $labelfont, 20, 155, "0%", $border);
     $fdate = $learning->changedate_display($from_date);
     $tdate = $learning->changedate_display($to_date);
     $days = $error_msg['cDays'] . " {$fdate} " . $error_msg['cTo'] . " {$tdate} ";
     $avg_comp = 160 - 140 / 100 * $avg;
     $avg = round($avg, 2);
     ImageStringUp($image, $labeltitlefont, 5, 110, $error_msg['cResults'], $border);
     ImageString($image, $labeltitlefont, 245, 20, $error_msg['cCommitment'], $border);
     ImageString($image, $labeltitlefont, 50, 170, "{$days}", $border);
     ImageString($image, $labeltitlefont, 50, 200, $error_msg['cCTimelyCompletionofActivities'], $border);
     ImageString($image, $labeltitlefont, 50, 185, $error_msg['cAverage'], $border);
     ImageString($image, $labeltitlefont, 115, 185, $avg, $border);
     ImageLine($image, 240, 20, 40, 160, $border1);
     //COMMITMENT LINE
     ImageLine($image, 240, $avg_comp, 40, 160, $border2);
     //AVERAGE COMPLETION
     ImageString($image, $labeltitlefont, 245, $avg_comp, $error_msg['cAccomplishment'], $border);
     header("Content-type: image/png");
     // or "Content-type: image/png"
     Imagepng($image);
     // or imagepng($image)
     ImageDestroy($image);
 }
Exemplo n.º 6
0
 /**
  * @throws Exception
  * 生成验证码 , 存放到token相对应的session里面
  */
 public function createCaptcha()
 {
     $token = $_COOKIE["token"];
     if (empty($token)) {
         throw new Exception("无法生产验证码,请稍后在试");
     }
     $string = "abcdefghijklmnopqrstuvwxyz0123456789";
     $str = "";
     for ($i = 0; $i < 4; $i++) {
         $pos = rand(0, 35);
         $str .= $string[$pos];
     }
     $this->load->library('session');
     $flag = $this->session->set_userdata($token . "_captcha", $str);
     $img_handle = Imagecreate(80, 20);
     //图片大小80X20
     $back_color = ImageColorAllocate($img_handle, 255, 255, 255);
     //背景颜色(白色)
     $txt_color = ImageColorAllocate($img_handle, 0, 0, 0);
     //文本颜色(黑色)
     //加入干扰线
     for ($i = 0; $i < 3; $i++) {
         $line = ImageColorAllocate($img_handle, rand(0, 255), rand(0, 255), rand(0, 255));
         Imageline($img_handle, rand(0, 15), rand(0, 15), rand(100, 150), rand(10, 50), $line);
     }
     //加入干扰象素
     for ($i = 0; $i < 200; $i++) {
         $randcolor = ImageColorallocate($img_handle, rand(0, 255), rand(0, 255), rand(0, 255));
         Imagesetpixel($img_handle, rand() % 100, rand() % 50, $randcolor);
     }
     Imagefill($img_handle, 0, 0, $back_color);
     //填充图片背景色
     ImageString($img_handle, 28, 20, 0, $str, $txt_color);
     //水平填充一行字符串
     ob_clean();
     // ob_clean()清空输出缓存区
     header("Content-type: image/png");
     //生成验证码图片
     Imagepng($img_handle);
     //显示图片
 }
Exemplo n.º 7
0
 function _output_image($destination_file, $image_type, $image)
 {
     //if destination file is empty image will be output to browser
     // right now $image_type can be JPEG or PNG
     global $ERR, $create_text;
     $destination_file = trim($destination_file);
     $res = false;
     //Create Text
     $white = ImageColorAllocate($image, 255, 255, 255);
     $black = ImageColorAllocate($image, 0, 0, 0);
     $red = ImageColorAllocate($image, 255, 0, 0);
     $blue = ImageColorAllocate($image, 0, 0, 255);
     $lightblue = ImageColorAllocate($image, 0, 128, 255);
     $green = ImageColorAllocate($image, 0, 255, 0);
     $violet = ImageColorAllocate($image, 225, 128, 225);
     $orange = ImageColorAllocate($image, 255, 128, 0);
     $gray = ImageColorAllocate($image, 192, 192, 192);
     $pink = ImageColorAllocate($image, 255, 0, 128);
     $brown = ImageColorAllocate($image, 128, 0, 0);
     $darkgreen = ImageColorAllocate($image, 0, 128, 0);
     ImageString($image, 3, 2, 1, $create_text, $white);
     if ($image) {
         switch ($image_type) {
             case 'JPEG':
             case 'JPG':
                 $res = ImageJpeg($image, $destination_file, $this->jpeg_quality);
                 break;
             case 'PNG':
                 $res = Imagepng($image, $destination_file);
                 break;
             default:
                 $this->error($ERR["UNKNOWN_OUTPUT_FORMAT"] . " {$image_type}");
                 break;
         }
     } else {
         $this->error($ERR["NO_IMAGE_FOR_OUTPUT"]);
     }
     if (!$res) {
         $this->error($ERR["UNABLE_TO_OUTPUT"] . " {$destination_file}");
     }
     return $res;
 }
Exemplo n.º 8
0
        $img = Imagegif($dst_img, '', $_quality_);
        $ob_contents = ob_get_contents();
        // Save file
        $fp = fopen("{$path}", 'wb');
        fwrite($fp, $ob_contents);
        fclose($fp);
        ob_end_flush();
    }
}
if (substr($_GET['img'], -3) == "png") {
    header("Content-type: image/png");
    if (file_exists($path)) {
        echo file_get_contents($path);
    } else {
        if (strnatcmp(phpversion(), '4.3.0') > 0) {
            $_quality_ = (int) ($_quality_ / 10);
        }
        $src_img = ImageCreateFromPng($_image_);
        $dst_img = imagecreatetruecolor($new_w, $new_h);
        ImagePaletteCopy($dst_img, $src_img);
        ImageCopyResized($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, ImageSX($src_img), ImageSY($src_img));
        ob_start();
        $img = Imagepng($dst_img, '', $_quality_);
        $ob_contents = ob_get_contents();
        // Save file
        $fp = fopen("{$path}", 'wb');
        fwrite($fp, $ob_contents);
        fclose($fp);
        ob_end_flush();
    }
}
Exemplo n.º 9
0
 /**
  * создание лого гильдии
  * @param string $hex
  * @param string $name
  * @param int $size
  * @param int $livetime
  * @return string
  */
 function GuildLogo($hex, $name, $size = 64, $livetime)
 {
     $path = "theme/imgs/guilds/";
     $name = str_replace(array("'", '"'), ' ', $name);
     $ftime = @filemtime($path . $name . "-" . $size . ".png");
     if (file_exists($path . $name . "-" . $size . ".png") && time() - $ftime <= $livetime) {
         return $path . $name . "-" . $size . ".png";
     } else {
         if (substr($hex, 0, 2) == "0x") {
             $hex = strtolower(substr($hex, 2));
         } else {
             $hex = strtolower($hex);
         }
         $pixelSize = $size / 8;
         $img = ImageCreate($size, $size);
         if (@preg_match('/[^a-zA-Z0-9]/', $hex) || $hex == '') {
             $hex = '0044450004445550441551554515515655555566551551660551166000566600';
         } else {
             $hex = stripslashes($hex);
         }
         for ($y = 0; $y < 8; $y++) {
             for ($x = 0; $x < 8; $x++) {
                 $offset = $y * 8 + $x;
                 switch (substr($hex, $offset, 1)) {
                     case "0":
                         $c1 = "0";
                         $c2 = "0";
                         $c3 = "0";
                         break;
                     case "1":
                         $c1 = "0";
                         $c2 = "0";
                         $c3 = "0";
                         break;
                     case "2":
                         $c1 = "128";
                         $c2 = "128";
                         $c3 = "128";
                         break;
                     case "3":
                         $c1 = "255";
                         $c2 = "255";
                         $c3 = "255";
                         break;
                     case "4":
                         $c1 = "255";
                         $c2 = "0";
                         $c3 = "0";
                         break;
                     case "5":
                         $c1 = "255";
                         $c2 = "128";
                         $c3 = "0";
                         break;
                     case "6":
                         $c1 = "255";
                         $c2 = "255";
                         $c3 = "0";
                         break;
                     case "7":
                         $c1 = "128";
                         $c2 = "255";
                         $c3 = "0";
                         break;
                     case "8":
                         $c1 = "0";
                         $c2 = "255";
                         $c3 = "0";
                         break;
                     case "9":
                         $c1 = "0";
                         $c2 = "255";
                         $c3 = "128";
                         break;
                     case "a":
                         $c1 = "0";
                         $c2 = "255";
                         $c3 = "255";
                         break;
                     case "b":
                         $c1 = "0";
                         $c2 = "128";
                         $c3 = "255";
                         break;
                     case "c":
                         $c1 = "0";
                         $c2 = "0";
                         $c3 = "255";
                         break;
                     case "d":
                         $c1 = "128";
                         $c2 = "0";
                         $c3 = "255";
                         break;
                     case "e":
                         $c1 = "255";
                         $c2 = "0";
                         $c3 = "255";
                         break;
                     case "f":
                         $c1 = "255";
                         $c2 = "0";
                         $c3 = "128";
                         break;
                     default:
                         $c1 = "255";
                         $c2 = "255";
                         $c3 = "255";
                         break;
                 }
                 $row[$x] = $x * $pixelSize;
                 $row[$y] = $y * $pixelSize;
                 $row2[$x] = $row[$x] + $pixelSize;
                 $row2[$y] = $row[$y] + $pixelSize;
                 $color[$y][$x] = imagecolorallocate($img, $c1, $c2, $c3);
                 imagefilledrectangle($img, $row[$x], $row[$y], $row2[$x], $row2[$y], $color[$y][$x]);
             }
         }
         Imagepng($img, $path . $name . "-" . $size . ".png");
         Imagedestroy($img);
         return $path . $name . "-" . $size . ".png";
     }
 }
Exemplo n.º 10
0
<?php

header("Content-type: image/png");
$string = "abcdefghijklmnopqrstuvwxyz0123456789";
$str = '';
for ($i = 0; $i < 6; $i++) {
    $pos = rand(0, 36);
    $str .= $string[$pos];
}
$img_handle = ImageCreate(60, 20) or die("Cannot Create image");
//Image size (x,y)
$back_color = ImageColorAllocate($img_handle, 255, 255, 255);
//Background color RBG
$txt_color = ImageColorAllocate($img_handle, 0, 0, 0);
//Text Color RBG
ImageString($img_handle, 31, 5, 0, $str, $txt_color);
Imagepng($img_handle);
session_start();
$_SESSION['img_number'] = $str;
Exemplo n.º 11
0
 public function createBarCode($image_type = 'png', $file_name = null)
 {
     $this->parseCode();
     $this->image = ImageCreate($this->width + 2 * $this->quiet_zone, $this->height + $this->font_height + $this->quiet_zone);
     $this->bgcolor = imagecolorallocate($this->image, $this->bgcolor >> 16, $this->bgcolor >> 8 & 0xff, $this->bgcolor & 0xff);
     $this->color = imagecolorallocate($this->image, $this->color >> 16, $this->color >> 8 & 0xff, $this->color & 0xff);
     ImageFilledRectangle($this->image, 0, 0, $this->width + 2 * $this->quiet_zone, $this->height + $this->font_height, $this->bgcolor);
     $sx = $this->quiet_zone;
     $sy = $this->font_height - 1;
     $fw = 10;
     //編號為2或3的字體的寬度為10,為4或5的字體寬度為11
     if ($this->font_type > 3) {
         $sy++;
         $fw = 11;
     }
     $ex = 0;
     if ($this->text) {
         //不显示号码,则生成满的条码
         if ($this->showType == 'top') {
             $ey = $this->height + $this->font_height - 2;
             //条码显示上方
         } else {
             if ($this->showType == 'bottom') {
                 $ey = $this->height - 2;
                 //条码显示下方
                 $sy = $this->quiet_zone;
             }
         }
     } else {
         $ey = $this->height + $this->font_height;
         $sy = $this->quiet_zone;
     }
     for ($i = 0; $i < strlen($this->bin_code); $i++) {
         $ex = $sx + $this->unit_width * (int) $this->bin_code[$i] - 1;
         if ($i % 2 == 0) {
             ImageFilledRectangle($this->image, $sx, $sy, $ex, $ey, $this->color);
         }
         $sx = $ex + 1;
     }
     if ($this->text) {
         //存在条码号再显示
         $t_num = strlen($this->text);
         $t_x = $this->width / $t_num;
         $t_sx = ($t_x - $fw) / 2;
         //目的为了使文字居中平均分布
         if ($this->showType == 'top') {
             $y = 0;
         } else {
             if ($this->showType == 'bottom') {
                 $y = $this->height;
             }
         }
         for ($i = 0; $i < $t_num; $i++) {
             imagechar($this->image, $this->font_type, 6 * $this->unit_width + $t_sx + $i * $t_x, $y, $this->text[$i], $this->color);
         }
     }
     if (!$file_name) {
         header("Content-Type: image/" . $image_type);
     }
     switch ($image_type) {
         case 'jpg':
         case 'jpeg':
             Imagejpeg($this->image, $file_name);
             break;
         case 'png':
             Imagepng($this->image, $file_name);
             break;
         case 'gif':
             break;
             Imagegif($this->image, $file_name);
         default:
             Imagepng($this->image, $file_name);
             break;
     }
 }
Exemplo n.º 12
0
/*
/* -------------- START ----------------------------------------------*/
/*$txt=$LDNoOccList;
ImageTTFText ($im, 15, 0, 9, 27, $black, "arial.ttf",$txt);
$txt=$LDFromWard.strtoupper($station);
ImageTTFText ($im, 15, 0, 9, 52, $black, "arial.ttf",$txt);
$txt=$LDWithinLast.($c-1).$LDDays;
ImageTTFText ($im, 15, 0, 9, 77, $black, "arial.ttf",$txt);
$txt=$LDAvailable;
ImageTTFText ($im, 15, 0, 9, 102, $black, "arial.ttf",$txt);
*/
/* -------------- END -------------------------------------------------*/
// ******************************************************************
// * the following code is the default - uses system fonts
// ******************************************************************
/* -------------- START  ----------------------*/
$txt = $LDNoOccList;
ImageString($im, 3, 9, 17, $txt, $black);
$txt = $LDFromWard . strtoupper($station);
ImageString($im, 3, 9, 42, $txt, $black);
$txt = $LDWithinLast;
ImageString($im, 3, 9, 67, $txt, $black);
$txt = $c - 1 . $LDDays . " " . $LDAvailable;
ImageString($im, 3, 9, 92, $txt, $black);
/* -------------- END --------------------------*/
Imagepng($im);
ImageDestroy($im);
?>


Exemplo n.º 13
0
 public static function beResizeImg($isrc, $idst, $iw, $ih, $ip = 'keep', $imax = 'yes', $iqual = 95)
 {
     /* parameters
        $isrc					source file
        $idst					destination folder
        $iw						new width
        $ih						new height
        $ip='keep'		keep proportions
        $imax='yes'		treat width/height as maximums
        $iqual=95			image quality
        */
     //read array with source image information
     $imagedata = getimagesize($isrc);
     //calculate new width and height
     $srcwid = $imagedata[0];
     $srchei = $imagedata[1];
     $srcx = $srcy = 0;
     //if no height is set we calculate it
     if ($ih == "full") {
         $ih = (int) ($imagedata[1] * ($iw / $imagedata[0]));
     }
     //the new width
     $new_iw = (int) $iw;
     //the new height
     if ($ip == 'keep') {
         //keep proportions
         $new_ih = (int) ($imagedata[1] * ($new_iw / $imagedata[0]));
         if ($new_ih > $ih) {
             $new_ih = (int) $ih;
             $new_iw = (int) ($imagedata[0] * ($new_ih / $imagedata[1]));
         }
     } else {
         //set fixed height
         $new_ih = (int) $ih;
         //crop
         if ($imagedata[0] / $new_iw < $imagedata[1] / $new_ih) {
             //original to heigh
             $srchei = (int) ($new_ih * ($imagedata[0] / $new_iw));
             $srcy = (int) (($imagedata[1] - $srchei) / 2);
         } elseif ($imagedata[0] / $new_iw > $imagedata[1] / $new_ih) {
             //original to wide
             $srcwid = (int) ($new_iw * ($imagedata[1] / $new_ih));
             $srcx = (int) (($imagedata[0] - $srcwid) / 2);
         }
     }
     //set image type and set image name
     $ipath = pathinfo($isrc);
     $itype = strtolower($ipath["extension"]);
     $iname = substr($ipath["basename"], 0, -(strlen($itype) + 1)) . "_" . $new_iw . "_" . $new_ih . "_" . $iqual . "." . $itype;
     //check if $idst is set to a subdirectory and if so add it to the path
     $idir = $idst != "" ? $ipath["dirname"] . "/" . $idst : $ipath["dirname"];
     //check if image exists, else create it
     if (!JFile::exists($idir . "/" . $iname)) {
         if ($itype == "jpg" && function_exists("imagecreatefromjpeg")) {
             $image = imagecreatefromjpeg($isrc);
             $image_dest = imagecreatetruecolor($new_iw, $new_ih);
             imagecopyresampled($image_dest, $image, 0, 0, $srcx, $srcy, $new_iw, $new_ih, $srcwid, $srchei);
             ob_start();
             // start a new output buffer
             imagejpeg($image_dest, NULL, $iqual);
             $buffer = ob_get_contents();
             ob_end_clean();
             // stop this output buffer
         } elseif ($itype == "gif" && function_exists("imagecreatefromgif")) {
             $image = imagecreatefromgif($isrc);
             $image_dest = imagecreatetruecolor($new_iw, $new_ih);
             imagealphablending($image_dest, false);
             // get and reallocate transparency-color
             $transindex = imagecolortransparent($image);
             if ($transindex >= 0) {
                 $transcol = imagecolorsforindex($image, $transindex);
                 $transindex = imagecolorallocatealpha($image_dest, $transcol['red'], $transcol['green'], $transcol['blue'], 127);
                 imagefill($image_dest, 0, 0, $transindex);
             }
             // resample
             imagecopyresampled($image_dest, $image, 0, 0, $srcx, $srcy, $new_iw, $new_ih, $srcwid, $srchei);
             // restore transparency
             if ($transindex >= 0) {
                 imagecolortransparent($image_dest, $transindex);
                 for ($y = 0; $y < $new_ih; ++$y) {
                     for ($x = 0; $x < $new_iw; ++$x) {
                         if ((imagecolorat($image_dest, $x, $y) >> 24 & 0x7f) >= 100) {
                             imagesetpixel($image_dest, $x, $y, $transindex);
                         }
                     }
                 }
             }
             imagetruecolortopalette($image_dest, true, 255);
             imagesavealpha($image_dest, false);
             ob_start();
             // start a new output buffer
             imagegif($image_dest, NULL, $iqual);
             $buffer = ob_get_contents();
             ob_end_clean();
             // stop this output buffer
         } elseif ($itype == "png" && function_exists("imagecreatefrompng")) {
             $image = ImageCreateFromPng($isrc);
             $image_dest = ImageCreateTrueColor($new_iw, $new_ih);
             $transindex = imagecolortransparent($image);
             $istruecolor = imageistruecolor($image);
             if ($transindex >= 0) {
                 ImageColorTransparent($image_dest, ImageColorAllocate($image_dest, 0, 0, 0));
                 ImageAlphaBlending($image_dest, false);
             } elseif (!$istruecolor) {
                 ImagePaletteCopy($image_dest, $image);
             } else {
                 ImageColorTransparent($image_dest, ImageColorAllocate($image_dest, 0, 0, 0));
                 ImageAlphaBlending($image_dest, false);
                 ImageSaveAlpha($image_dest, true);
             }
             ImageCopyResized($image_dest, $image, 0, 0, $srcx, $srcy, $new_iw, $new_ih, $srcwid, $srchei);
             $iqual_png = 100 - $iqual;
             if (substr(phpversion(), 0, 1) >= 5) {
                 $iqual_png = intval(($iqual - 10) / 10);
             }
             ob_start();
             // start a new output buffer
             Imagepng($image_dest, NULL, $iqual_png);
             $buffer = ob_get_contents();
             ob_end_clean();
             // stop this output buffer
         }
         if (isset($buffer) && $buffer != "") {
             JFile::write($idir . '/' . $iname, $buffer);
             unset($buffer);
         }
         if (isset($image)) {
             imagedestroy($image);
         }
         if (isset($image_dest)) {
             imagedestroy($image_dest);
         }
     }
     //utf8_encode and rawurlencode file name
     $iname = rawurlencode(utf8_encode($iname));
     //return path/filename/type/width/height
     return $thenewimage = array($idir . '/' . $iname, $iname, $itype, $new_iw, $new_ih);
 }
Exemplo n.º 14
0
 function imageResize()
 {
     global $engine_path, $ImageTrimX, $ImageTrimY;
     $source = $this->image;
     $newWidth = $this->newWidth;
     $newHeight = $this->newHeight;
     $imType = $this->type;
     if ($imType == "jpeg" || $imType == "pjpeg") {
         $srcImage = ImageCreateFromJPEG($source);
     } elseif ($imType == "gif") {
         $srcImage = LoadGif($source);
     } else {
         $srcImage = ImageCreateFromPNG($source);
     }
     $srcWidth = ImageSX($srcImage);
     $srcHeight = ImageSY($srcImage);
     $ratioWidth = $srcWidth / $newWidth;
     $ratioHeight = $srcHeight / $newHeight;
     if ($ratioWidth < 1 && $this->fix == "width" || $ratioHeight < 1 && $this->fix == "height") {
         $destWidth = $srcWidth;
         $destHeight = $srcHeight;
         //print "mode 1";
         //exit;
     } elseif ($ratioWidth > $ratioHeight || $ratioWidth < $ratioHeight && $this->fix != "width" || $this->fix == "height") {
         $destWidth = $srcWidth / $ratioHeight;
         $destHeight = $newHeight;
         //print "mode 2";
         //exit;
     } else {
         $destWidth = $newWidth;
         $destHeight = $srcHeight / $ratioWidth;
         //print "mode 3 $ratioHeight $ratioWidth $this->fix";
         //exit;
     }
     //$this->newWidth=$destWidth;
     //$this->newHeight=$desHeight;
     //print "$this->newWidth - $this->newHeight";
     //print $srcImage." $ratioWidth $ratioHeight $this->fix $destWidth $destHeight";
     //print "-($newHeight-$destHeight)/2";
     //exit;
     if ($newWidth != $srcWidth && $newHeight != $srcHeight && $newWidth != 160) {
         if (!strlen($ImageTrim)) {
             $ImageTrim = 2;
         }
         if ($ImageTrimY == 0) {
             $y = 0;
         } elseif ($ImageTrimY == 1) {
             $y = ($newHeight - $destHeight) / 4;
         } elseif ($ImageTrimY == 2) {
             $y = ($newHeight - $destHeight) / 2;
         } elseif ($ImageTrimY == 3) {
             $y = 3 * ($newHeight - $destHeight) / 2;
         } elseif ($ImageTrimY == 4) {
             $y = 5 * ($newHeight - $destHeight) / 2;
         }
         if ($ImageTrimX == 0) {
             $x = 0;
         } elseif ($ImageTrimX == 1) {
             $x = ($newWidth - $destWidth) / 4;
         } elseif ($ImageTrimX == 2) {
             $x = ($newWidth - $destWidth) / 2;
         } elseif ($ImageTrimX == 3) {
             $x = 3 * ($newWidth - $destWidth) / 2;
         } elseif ($ImageTrimX == 4) {
             $x = 5 * ($newWidth - $destWidth) / 2;
         }
         //print "$ImageTrimY $ImageTrimX $x $y";
         //exit;
         $destImage = imagecreatetruecolor($newWidth, $newHeight);
         imagecopyresampled($destImage, $srcImage, $x, $y, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
     } else {
         $destImage = imagecreatetruecolor($destWidth, $destHeight);
         imagecopyresampled($destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
     }
     if ($this->mix) {
         $destImage = $this->mix($destImage);
     }
     $name = $engine_path . "img/small/" . $this->name;
     if ($imType == "jpeg" || $imType == "pjpeg") {
         Imagejpeg($destImage, $name);
     } elseif ($imType == "gif") {
         Imagegif($destImage, $name);
     } else {
         Imagepng($destImage, $name);
     }
     $file['tmp_name'] = $name;
     ImageDestroy($srcImage);
     ImageDestroy($destImage);
     return $file;
 }
Exemplo n.º 15
0
 function createThumb($upfile, $dstfile, $max_width, $max_height)
 {
     $size = getimagesize($upfile);
     $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;
     } elseif ($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['mime'] == "image/jpeg") {
         $src = ImageCreateFromJpeg($upfile);
         $dst = ImageCreateTrueColor($tn_width, $tn_height);
         imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height, $width, $height);
         imageinterlace($dst, true);
         ImageJpeg($dst, $dstfile, 100);
     } else {
         if ($size['mime'] == "image/png") {
             $src = ImageCreateFrompng($upfile);
             $dst = ImageCreateTrueColor($tn_width, $tn_height);
             imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height, $width, $height);
             // integer representation of the color black (rgb: 0,0,0)
             $background = imagecolorallocate($dst, 255, 255, 0);
             // removing the black from the placeholder
             imagecolortransparent($dst, $background);
             // turning off alpha blending (to ensure alpha channel information
             // is preserved, rather than removed (blending with the rest of the
             // image in the form of black))
             imagealphablending($dst, false);
             // turning on alpha channel information saving (to ensure the full range
             // of transparency is preserved)
             imagesavealpha($dst, true);
             Imagepng($dst, $dstfile);
         } else {
             $src = ImageCreateFromGif($upfile);
             $dst = ImageCreateTrueColor($tn_width, $tn_height);
             imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height, $width, $height);
             imagegif($dst, $dstfile);
         }
     }
 }
Exemplo n.º 16
0
 function imageResize()
 {
     global $engine_path, $ImageTrimX, $ImageTrimY;
     $source = $this->image;
     $newWidth = $this->newWidth;
     $newHeight = $this->newHeight;
     $imType = $this->type;
     if (!$imType || $imType == "jpeg" || $imType == "pjpeg") {
         $srcImage = ImageCreateFromJPEG($source);
     } elseif ($imType == "gif") {
         $srcImage = LoadGif($source);
     } else {
         $srcImage = ImageCreateFromPNG($source);
     }
     $srcWidth = ImageSX($srcImage);
     $srcHeight = ImageSY($srcImage);
     $ratioWidth = $srcWidth / $newWidth;
     $ratioHeight = $srcHeight / $newHeight;
     if ($ratioWidth < 1 && $this->fix == "width" || $ratioHeight < 1 && $this->fix == "height") {
         $destWidth = $srcWidth;
         $destHeight = $srcHeight;
         $mode = 1;
     } elseif ($ratioWidth > $ratioHeight && $newHeight != 120 || $ratioWidth < $ratioHeight && $this->fix != "width" || $this->fix == "height") {
         $destWidth = $srcWidth / $ratioHeight;
         $destHeight = $newHeight;
         $mode = 2;
     } else {
         $destWidth = $newWidth;
         $destHeight = $srcHeight / $ratioWidth;
         $mode = 3;
     }
     //print "$ratioWidth > $ratioHeight) || ( $ratioWidth < $ratioHeight && $this->fix ".$mode;
     //exit;
     if ($newWidth != $srcWidth && $newHeight != $srcHeight && $newWidth != 160 && $mode != 1 && $newHeight != 120) {
         if (!strlen($ImageTrim)) {
             $ImageTrim = 2;
         }
         if ($newy) {
             $y = $newy;
         } elseif ($ImageTrimY == 0) {
             $y = 0;
         } elseif ($ImageTrimY == 1) {
             $y = ($newHeight - $destHeight) / 4;
         } elseif ($ImageTrimY == 2) {
             $y = ($newHeight - $destHeight) / 2;
         } elseif ($ImageTrimY == 3) {
             $y = 3 * ($newHeight - $destHeight) / 2;
         } elseif ($ImageTrimY == 4) {
             $y = 5 * ($newHeight - $destHeight) / 2;
         }
         if ($newx) {
             $x = $newx;
         } elseif ($ImageTrimX == 0) {
             $x = 0;
         } elseif ($ImageTrimX == 1) {
             $x = ($newWidth - $destWidth) / 4;
         } elseif ($ImageTrimX == 2) {
             $x = ($newWidth - $destWidth) / 2;
         } elseif ($ImageTrimX == 3) {
             $x = 3 * ($newWidth - $destWidth) / 2;
         } elseif ($ImageTrimX == 4) {
             $x = 5 * ($newWidth - $destWidth) / 2;
         }
         $destImage = imagecreatetruecolor($newWidth, $newHeight);
         imagecopyresampled($destImage, $srcImage, $x, $y, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
     } else {
         $destImage = imagecreatetruecolor($destWidth, $destHeight);
         imagecopyresampled($destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
     }
     $this->newWidth = $destWidth;
     $this->newHeight = $destHeight;
     if ($this->mix) {
         $destImage = $this->mix($destImage);
     }
     $name = $engine_path . "tmp/" . $this->name;
     if (!file_exists($engine_path . "tmp/")) {
         mkdir_r($engine_path . "tmp/");
     }
     if ($imType == "jpeg" || $imType == "pjpeg") {
         Imagejpeg($destImage, $name);
     } elseif ($imType == "gif") {
         Imagegif($destImage, $name);
     } else {
         Imagepng($destImage, $name);
     }
     $file['tmp_name'] = $name;
     ImageDestroy($srcImage);
     ImageDestroy($destImage);
     return $file;
 }
Exemplo n.º 17
0
 function display($db_object, $common, $user_id, $default, $error_msg, $learning, $get_var)
 {
     $width = 340;
     $height = 220;
     $labelfont = 2;
     $labelfont1 = 1;
     $labeltitlefont = '3';
     $image = ImageCreate($width, $height);
     while (list($kk, $vv) = @each($get_var)) {
         ${$kk} = $vv;
     }
     //from table
     $config_table = $common->prefix_table("config");
     $color_qry = "select commit_color,accomplish_color from {$config_table} where id='1'";
     $res = $db_object->get_a_line($color_qry);
     $ccolor = $res['commit_color'];
     $acolor = $res['accomplish_color'];
     $com = $common->split_color($db_object, $ccolor);
     $accom = $common->split_color($db_object, $acolor);
     $p1 = "0x{$com['0']}";
     $p2 = "0x{$com['1']}";
     $p3 = "0x{$com['2']}";
     $p1 = hexdec($p1);
     $p2 = hexdec($p2);
     $p3 = hexdec($p3);
     $bgcolor = ImageColorAllocate($image, 0xffffff, 0xffffff, 0xffffff);
     $border = ImageColorAllocate($image, 0x0, 0x0, 0x0);
     $commit_color = imagecolorallocate($image, $p1, $p2, $p3);
     $red = imagecolorallocate($image, 0xff, 0x0, 0x0);
     $green = imagecolorallocate($image, 0x33, 0xcc, 0x0);
     /* to check 
     		$date_array = "2003-11-15,2003-11-20,2003-11-30";
     		$fulfilled_array = "25,150,10";
     		$fromdate = "2003-11-13";
     		$todate	="2003-12-01";	*/
     $fdate = $fromdate;
     $tdate = $todate;
     $fulfilled_array = @explode(",", $fulfilled_array);
     $date_array = @explode(",", $date_array);
     $to = split("-", $tdate);
     $from = split("-", $fdate);
     $dt1 = mktime(0, 0, 0, $to[1], $to[2], $to[0]);
     $dt2 = mktime(0, 0, 0, $from[1], $from[2], $from[0]);
     $dt3 = $dt1 - $dt2;
     $daydiff = $dt3 / 60 / 60 / 24;
     $days = $error_msg['cDays'] . " {$fdate} " . $error_msg['cTo'] . " {$tdate} ";
     ImageRectangle($image, 65, 24, 315, 180, $border);
     ImageString($image, $labelfont, 15, 19, $error_msg['cExceeds'], $border);
     ImageString($image, $labelfont, 40, 94, $error_msg['cMet'], $border);
     ImageString($image, $labelfont, 5, 170, $error_msg['cFellshort'], $border);
     ImageString($image, $labeltitlefont, 70, 182, "{$days}", $border);
     Imageline($image, 65, 102, 315, 102, $commit_color);
     ImageStringUp($image, $labeltitlefont, 15, 140, $error_msg['cExpectation'], $border);
     $x1 = 65;
     //$y1 = 180;
     $startx_val = $x1;
     $starty_val = 180;
     //$x2 = 130;
     //$y2 = 95;
     $p1 = "0x{$accom['0']}";
     $p2 = "0x{$accom['1']}";
     $p3 = "0x{$accom['2']}";
     $p1 = hexdec($p1);
     $p2 = hexdec($p2);
     $p3 = hexdec($p3);
     $accomplish_color = imagecolorallocate($image, $p1, $p2, $p3);
     $min = 63;
     $max = 311;
     $tot = $max - $min;
     $count = $daydiff;
     $interval = @($tot / $count);
     $interval = sprintf("%01.0f", $interval);
     //ImageString($image, $labelfont, 15,40, "$fulfilled_array", $border);
     for ($j = 0; $j <= $count; $j++) {
         if ($min <= $max) {
             ImageString($image, $labelfont1, $min, 176, "|", $border);
         }
         $min = $min + $interval;
     }
     $d_array = array();
     $inc = 40;
     $im_dates = split("-", $fdate);
     //to calculate the x2 value
     $odd = array("01", "03", "05", "07", "08", "10", "12");
     //Odd months
     $even = array("04", "06", "09", "11");
     //even months
     for ($d = 0; $d < count($date_array); $d++) {
         $start_date = $im_dates[2];
         $ar = $date_array[$d];
         $im_da = split("-", $ar);
         $dte = $im_da[2];
         $m = $im_da[1];
         for ($c = 0; $c <= $daydiff; $c++) {
             if ($dte == $start_date) {
                 $dt_array[] = $c;
             }
             $start_date = $start_date + 1;
             if (in_array($m, $odd)) {
                 if ($start_date == 32) {
                     $start_date = 1;
                     $m = $m + 1;
                     if ($m == 13) {
                         $m = 1;
                     }
                 }
             } elseif (in_array($m, $even)) {
                 if ($start_date == 31) {
                     $start_date = 1;
                     $m = $m + 1;
                     if ($m == 13) {
                         $m = 1;
                     }
                 }
             } else {
                 if ($start_date == 29) {
                     $start_date = 1;
                     $m = $m + 1;
                 }
             }
             //ImageString($image, $labelfont, 50,$inc,"$start_date", $border);
             $inc = $inc + 15;
         }
     }
     $inc = 50;
     for ($i = 0; $i < count($fulfilled_array) - 1; $i++) {
         $ful = $fulfilled_array[$i];
         $dt_val = $dt_array[$i + 1];
         $x2 = $startx_val + $interval * $dt_val;
         //cal using No of Days
         $div = $ful / 25;
         $y1 = $starty_val - 19.5 * $div;
         $ful2 = $fulfilled_array[$i + 1];
         $div2 = $ful2 / 25;
         $y2 = $starty_val - 19.5 * $div2;
         ImageLine($image, $x1, $y1, $x2, $y2, $accomplish_color);
         $x1 = $x2;
         //$y1 = $y2;
         $d_array = "";
         //ImageString($image, $labelfont1,80,$inc,"$x1 : $y1 : $x2 : $y2",$border);
         $inc = $inc + 10;
     }
     header("Content-type: image/png");
     Imagepng($image);
     ImageDestroy($image);
 }
Exemplo n.º 18
0
function uploadimg($filename, $width, $get_height, $path)
{
    if (trim($_FILES["image"]["tmp_name"]) != "") {
        $tmp_images = $_FILES["image"]["tmp_name"];
        // type select
        if ($_FILES['image']['type'] == 'image/jpeg' or $_FILES['image']['type'] == 'image/jpg' or $_FILES['image']['type'] == 'image/pjpeg') {
            $images = $filename . ".jpg";
            //upload source image
            $size = getimagesize($tmp_images);
            //check radio widht and height
            $height = round($width * $size[1] / $size[0]);
            if ($height > $get_height) {
                $width = round($get_height * $size[0] / $size[1]);
                $height = $get_height;
            }
            $images_orig = ImageCreateFromJPEG($tmp_images);
            $photoX = ImagesX($images_orig);
            $photoY = ImagesY($images_orig);
            $images_fin = ImageCreateTrueColor($width, $height);
            ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width + 1, $height + 1, $photoX, $photoY);
            ImageJPEG($images_fin, $path . $images);
            ImageDestroy($images_orig);
            ImageDestroy($images_fin);
            return $filename . ".jpg";
        } elseif ($_FILES['image']['type'] == 'image/x-png' or $_FILES['image']['type'] == 'image/png') {
            $images = $filename . ".png";
            $size = getimagesize($tmp_images);
            //check radio widht and height
            $height = round($width * $size[1] / $size[0]);
            if ($height > $get_height) {
                $width = round($get_height * $size[0] / $size[1]);
                $height = $get_height;
            }
            $images_orig = ImageCreateFromPNG($tmp_images);
            $photoX = ImagesX($images_orig);
            $photoY = ImagesY($images_orig);
            $images_fin = ImageCreateTrueColor($width, $height);
            ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width + 1, $height + 1, $photoX, $photoY);
            Imagepng($images_fin, $path . $images);
            ImageDestroy($images_orig);
            ImageDestroy($images_fin);
            return $filename . ".png";
        } elseif ($_FILES['image']['type'] == 'image/gif') {
            $images = $filename . ".gif";
            $size = getimagesize($tmp_images);
            //check radio widht and height
            $height = round($width * $size[1] / $size[0]);
            if ($height > $get_height) {
                $width = round($get_height * $size[0] / $size[1]);
                $height = $get_height;
            }
            $images_orig = ImageCreateFromgif($tmp_images);
            $photoX = ImagesX($images_orig);
            $photoY = ImagesY($images_orig);
            $images_fin = ImageCreateTrueColor($width, $height);
            ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width + 1, $height + 1, $photoX, $photoY);
            Imagegif($images_fin, $path . $images);
            ImageDestroy($images_orig);
            ImageDestroy($images_fin);
            return $filename . ".gif";
        } else {
            return FALSE;
        }
    }
}
Exemplo n.º 19
0
 function geraFotos($fotoOriginal)
 {
     list($imagewidth, $imageheight, $img_type) = @GetImageSize($fotoOriginal);
     $src_img_original = "";
     $fim_largura = $imagewidth;
     $fim_altura = $imageheight;
     $extensao = $img_type == "2" ? ".jpg" : ($img_type == "3" ? ".png" : "");
     $nome_do_arquivo = array_pop(explode("/", $fotoOriginal));
     //date('Y-m-d')."-".substr(md5($fotoOriginal), 0, 10).$extensao;
     $caminhoDaBig = "arquivos/acoes/fotos/big/{$nome_do_arquivo}";
     $caminhoDaFotoOriginal = "arquivos/acoes/fotos/original/{$nome_do_arquivo}";
     if ($imagewidth > 700) {
         $new_w = 700;
         $ratio = $imagewidth / $new_w;
         $new_h = ceil($imageheight / $ratio);
         $fim_largura = $new_w;
         $fim_altura = $new_h;
         if (!file_exists($caminhaDaBig)) {
             if ($img_type == "2") {
                 $src_img_original = @imagecreatefromjpeg($fotoOriginal);
                 $dst_img = @imagecreatetruecolor($new_w, $new_h);
                 imagecopyresized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img_original), imagesy($src_img_original));
                 imagejpeg($dst_img, $caminhoDaBig);
             } else {
                 if ($img_type == "3") {
                     $src_img_original = @ImageCreateFrompng($fotoOriginal);
                     $dst_img = @imagecreatetruecolor($new_w, $new_h);
                     ImageCopyResized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, ImageSX($src_img_original), ImageSY($src_img_original));
                     Imagepng($dst_img, $caminhoDaBig);
                 }
             }
         }
     } else {
         if (!file_exists($caminhoDaBig)) {
             copy($fotoOriginal, $caminhoDaBig);
             if ($img_type == "2") {
                 $src_img_original = @imagecreatefromjpeg($fotoOriginal);
             } else {
                 if ($img_type == "3") {
                     $src_img_original = @imagecreatefrompng($fotoOriginal);
                 }
             }
         }
     }
     $new_w = 100;
     $ratio = $imagewidth / $new_w;
     $new_h = round($imageheight / $ratio);
     $caminhoDaSmall = "arquivos/acoes/fotos/small/{$nome_do_arquivo}";
     if (!file_exists($caminhaDaBig)) {
         if ($img_type == "2") {
             $dst_img = @imagecreatetruecolor($new_w, $new_h);
             @imagecopyresized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img_original), imagesy($src_img_original));
             @imagejpeg($dst_img, $caminhoDaSmall);
         } else {
             if ($img_type == "3") {
                 $dst_img = @imagecreatetruecolor($new_w, $new_h);
                 @imageCopyResized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, ImageSX($src_img_original), imageSY($src_img_original));
                 @imagepng($dst_img, $caminhoDaSmall);
             }
         }
     }
     copy($fotoOriginal, $caminhoDaFotoOriginal);
     if (!(file_exists($fotoOriginal) && file_exists($caminhoDaSmall) && file_exists($caminhoDaBig))) {
         die("<center><br>Um erro ocorreu ao inserir a foto.<br>Por favor tente novamente.</center>");
     }
 }
 function setThumbnail($file, $upload_dir = ".", $thumbnail_upload_dir = "./thumb", $filename = "", $thumbnail_size = 250, $thumbnail_quality = 76, $limit_size = 2, $type = 1, $check = 0, $image_type = 0, $image_width = 800, $image_height = 600, $limit_length = 30)
 {
     if ($filename == "") {
         $filename = $file[name];
     }
     $img_size = $this->setFileUpload($file, $upload_dir, $filename, $limit_size, $type, $check, $image_type, $image_width, $image_height = 600, $limit_length = 30);
     //앨범에서의 썸네일 이미지를 위해 JPG GD를 사용하여 썸네일 이미지를 생성한다.
     if ($img_size[0] > $img_size[1]) {
         //가로방향 이미지
         if ($img_size[0] > $thumbnail_size) {
             $img_width = $thumbnail_size;
             $img_height = $img_size[1] * $thumbnail_size / $img_size[0];
         } else {
             $img_width = $img_size[0];
             $img_height = $img_size[1];
         }
     } else {
         //세로방향 이미지
         if ($img_size[1] > $thumbnail_size) {
             $img_width = $img_size[0] * $thumbnail_size / $img_size[1];
             $img_height = $thumbnail_size;
         } else {
             $img_width = $img_size[0];
             $img_height = $img_size[1];
         }
     }
     if ($file[type] == "image/pjpeg" && (eregi("\\.jpg\$", $file[name]) || eregi("\\.jpeg\$", $file[name])) && $this->varGDPermit[jpg] == 'Y') {
         $dst_img = ImageCreate($img_width, $img_height);
         // 위에서 계산한대로 빈 이미지 파일을 만듭니다.
         $src_img = ImageCreateFromjpeg("{$upload_dir}/{$filename}");
         // 이미지파일을 읽어들입니다.
         ImageCopyResized($dst_img, $src_img, 0, 0, 0, 0, $img_width, $img_height, ImageSX($src_img), ImageSY($src_img));
         //빈 이미지에다 원본이미지를 줄여서 그립니다.
         $creat_file_name = "{$thumbnail_upload_dir}/{$filename}";
         Imagejpeg($dst_img, $creat_file_name, $thumbnail_quality);
         // thumb 디렉토리에 원본과 같은 이름의 jpeg으로 저장합니다. 76이라는 숫자는 퀄리티인데요, 높을수록 용량크고 질이 좋아집니다.
     } else {
         if ($file[type] == "image/x-png" && eregi("\\.png\$", $file[name]) && $this->varGDPermit[png] == 'Y') {
             $dst_img = ImageCreate($img_width, $img_height);
             // 위에서 계산한대로 빈 이미지 파일을 만듭니다.
             $src_img = ImageCreateFrompng("{$upload_dir}/{$filename}");
             // 이미지파일을 읽어들입니다.
             ImageCopyResized($dst_img, $src_img, 0, 0, 0, 0, $img_width, $img_height, ImageSX($src_img), ImageSY($src_img));
             //빈 이미지에다 원본이미지를 줄여서 그립니다.
             $creat_file_name = "{$thumbnail_upload_dir}/{$filename}";
             Imagepng($dst_img, $creat_file_name, $thumbnail_quality);
             // thumb 디렉토리에 원본과 같은 이름의 jpeg으로 저장합니다. 76이라는 숫자는 퀄리티인데요, 높을수록 용량크고 질이 좋아집니다.
         } else {
             if ($file[type] == "image/gif" && eregi("\\.gif\$", $file[name]) && $this->varGDPermit[gif] == 'Y') {
                 $dst_img = ImageCreate($img_width, $img_height);
                 // 위에서 계산한대로 빈 이미지 파일을 만듭니다.
                 $src_img = ImageCreateFromgif("{$upload_dir}/{$filename}");
                 // 이미지파일을 읽어들입니다.
                 ImageCopyResized($dst_img, $src_img, 0, 0, 0, 0, $img_width, $img_height, ImageSX($src_img), ImageSY($src_img));
                 //빈 이미지에다 원본이미지를 줄여서 그립니다.
                 $creat_file_name = "{$thumbnail_upload_dir}/{$filename}";
                 Imagegif($dst_img, $creat_file_name, $thumbnail_quality);
                 // thumb 디렉토리에 원본과 같은 이름의 jpeg으로 저장합니다. 76이라는 숫자는 퀄리티인데요, 높을수록 용량크고 질이 좋아집니다.
             } else {
                 $this->errmsg("{$file['type']}은 GD를 지원하지 않습니다!!");
             }
         }
     }
     ImageDestroy($dst_img);
     //로드한 메모리를 비워줍니다. gd는 꼭 이걸 해주어야 합니다.
     ImageDestroy($src_img);
 }
Exemplo n.º 21
0
    ImageFilledRectangle($label, 30, $ltop, 34, $bot, $red);
}
if ($result['green_pale'] == 2) {
    ImageFilledRectangle($label, 35, 0, 39, $bot, $green_pale);
} else {
    ImageFilledRectangle($label, 35, $ltop, 39, $bot, $green_pale);
}
if ($result['violet'] == 2) {
    ImageFilledRectangle($label, 40, 0, 44, $bot, $violet);
} else {
    ImageFilledRectangle($label, 40, $ltop, 44, $bot, $violet);
}
if ($result['blue'] == 2) {
    ImageFilledRectangle($label, 45, 0, 49, $bot, $blue);
} else {
    ImageFilledRectangle($label, 45, $ltop, 49, $bot, $blue);
}
if ($result['biege'] == 2) {
    ImageFilledRectangle($label, 50, 0, 54, $bot, $biege);
} else {
    ImageFilledRectangle($label, 50, $ltop, 54, $bot, $biege);
}
if ($result['orange'] == 2) {
    ImageFilledRectangle($label, 55, 0, 59, $bot, $orange);
} else {
    ImageFilledRectangle($label, 55, $ltop, 59, $bot, $orange);
}
/* Draw the black horizontal bottom line */
ImageLine($label, 0, $bot, 59, $bot, $black);
Imagepng($label);
ImageDestroy($label);
Exemplo n.º 22
0
function fUploadimg_process($file, $Store_dir, $simp = "N")
{
    global $config, $_POST;
    $mime_types = array('gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/pjpeg', 'jpe' => 'image/jpeg', 'bmp' => 'image/bmp', 'png' => 'image/png', 'ppng' => 'image/x-png', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'pict' => 'image/x-pict', 'pic' => 'image/x-pict', 'pct' => 'image/x-pict', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'psd' => 'image/x-photoshop', 'swf' => 'application/x-shockwave-flash', 'js' => 'application/x-javascript', 'pdf' => 'application/pdf', 'ps' => 'application/postscript', 'eps' => 'application/postscript', 'ai' => 'application/postscript', 'wmf' => 'application/x-msmetafile', 'mid' => 'audio/midi', 'wav' => 'audio/wav', 'mp3' => 'audio/mpeg', 'mp2' => 'audio/mpeg', 'avi' => 'video/x-msvideo', 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'qt' => 'video/quicktime', 'mov' => 'video/quicktime', 'lha' => 'application/x-lha', 'lzh' => 'application/x-lha', 'z' => 'application/x-compress', 'gtar' => 'application/x-gtar', 'gz' => 'application/x-gzip', 'gzip' => 'application/x-gzip', 'tgz' => 'application/x-gzip', 'tar' => 'application/x-tar', 'bz2' => 'application/bzip2', 'zip' => 'application/zip', 'arj' => 'application/x-arj', 'rar' => 'application/octet-stream', 'rars' => 'application/x-rar-compressed', 'word' => 'application/msword');
    if (in_array($file['type'], $mime_types) && $file['error'] == '0') {
        $Image = explode(".", $file['name']);
        $Num = count($Image) - 1;
        $Suffix = strtolower($Image[$Num]);
        $Fname = date("YmdHis") . $_POST['fileKey'];
        if ($file['size'] > $config['size']) {
            header("Location: update.php?action=error&error=" . urlencode("文件太大不能上传"));
            exit;
        }
        //fMessage('file max');
        if ($file['size'] == 0) {
            header("Location: update.php?action=error&error=" . urlencode("文件不能为空信息"));
            exit;
        }
        if (is_dir(R_P . $Store_dir) !== TRUE) {
            mkdir(R_P . $Store_dir, 0777);
        }
        $Picpath = R_P . $Store_dir . $Fname . "." . $Suffix;
        if (!copy($file['tmp_name'], $Picpath)) {
            if (!move_uploaded_file($file['tmp_name'], $Picpath)) {
                fMessage('file lost', "index.php?action=member&option=info");
            }
        }
        chmod($Picpath, 0777);
        if ($simp != "N") {
            $PicSource = R_P . $Store_dir . $simp . $Fname . "." . $Suffix;
            if (is_dir(R_P . $Store_dir . $simp) !== TRUE) {
                mkdir(R_P . $Store_dir . $simp, 0777);
            }
            if ($file['type'] == 'image/gif') {
                $im = imagecreatefromgif($Picpath);
            } elseif ($file['type'] == 'image/jpeg' || ($file['type'] = 'image/pjpeg')) {
                $im = imagecreatefromjpeg($Picpath);
            } else {
                $im = imagecreatefrompng($Picpath);
            }
            $srcW = ImageSX($im);
            $srcH = ImageSY($im);
            if ($srcW < 120 && $srcH < 120) {
                copy($Picpath, $PicSource);
            } else {
                if ($srcW > $srcH) {
                    $withe = 120;
                    $height = intval($withe * $srcH / $srcW);
                } elseif ($srcH > $srcW) {
                    $height = 120;
                    $withe = intval($height * $srcW / $srcH);
                } else {
                    $height = $srcH;
                    $withe = $srcW;
                }
                //$ni=ImageCreate($withe,$heigh);//建立一张空图
                $ni = imagecreatetruecolor($withe, $height);
                //建立一张空图
                imagealphablending($ni, false);
                ImageCopyResized($ni, $im, 0, 0, 0, 0, $withe, $height, $srcW, $srcH);
                //按0,0,0,0的坐标开始
                if ($file['type'] == 'image/gif') {
                    imagegif($ni, $PicSource);
                } elseif ($file['type'] == 'image/jpeg') {
                    imagejpeg($ni, $PicSource);
                } else {
                    Imagepng($ni, $PicSource);
                }
            }
            chmod($PicSource, 0777);
        }
        return $Fname . "." . $Suffix;
    }
    header("Location: update.php?action=error&error=" . urlencode("上传文件格式不符合"));
    die("上传文件格式不符合");
}
Exemplo n.º 23
0
{
	if(((!$gd_info['FreeType Support']) || (!file_exists($schriftdatei))))
	{
		if($sm_shadowcolor)
		{
			imagestring($img, 2, (($width - (strlen(trim($output[$i])) * $schriftwidth) - 2) / 2 + 1), ($i * $schriftheight + 6), trim($output[$i]), $txt2color);
		}
		imagestring($img, 2, (($width - (strlen(trim($output[$i])) * $schriftwidth) - 2) / 2), ($i * $schriftheight + 5), trim($output[$i]), $txtcolor);
	}
	else
	{
		if($sm_shadowcolor)
		{
			imagettftext($img, $schriftheight, 0, (($width - (strlen(trim($output[$i])) * $schriftwidth) - 2) / 2 + 1), ($i * $schriftheight + $schriftheight + 4), $txt2color, $schriftdatei, trim($output[$i]));
		}
		imagettftext($img, $schriftheight, 0, (($width - (strlen(trim($output[$i])) * $schriftwidth) - 2) / 2), ($i * $schriftheight + $schriftheight + 3), $txtcolor, $schriftdatei, trim($output[$i]));
	}
	$i++;
}

imagecolortransparent($img, $bgcolor);  // Dummybg als transparenz setzen
imageinterlace($img, 1);

header('Content-Type: image/png');
Imagepng($img);   // 100 = komprimierung
//Imagepng($img,'',100);   // 100 = komprimierung
ImageDestroy($img);
ImageDestroy($schild);
ImageDestroy($smilie);

?>
Exemplo n.º 24
0
 /**
  * 指定サイズで画像を出力する.
  *
  * @param string  $FromImgPath ファイル名までのパス
  * @param string  $ToImgPath   出力先パス
  * @param integer $tmpMW       最大横幅
  * @param integer $tmpMH       最大縦幅
  * @param integer $newFileName 新ファイル名
  * @param array 新ファイル名を格納した配列
  */
 public function MakeThumb($FromImgPath, $ToImgPath, $tmpMW, $tmpMH, $newFileName = '')
 {
     // 画像の最大横幅(単位:ピクセル)
     $ThmMaxWidth = LARGE_IMAGE_WIDTH;
     // 画像の最大縦幅(単位:ピクセル)
     $ThmMaxHeight = LARGE_IMAGE_HEIGHT;
     //拡張子取得
     $array_ext = explode('.', $FromImgPath);
     $ext = $array_ext[count($array_ext) - 1];
     $MW = $ThmMaxWidth;
     if ($tmpMW) {
         $MW = $tmpMW;
     }
     // $MWに最大横幅セット
     $MH = $ThmMaxHeight;
     if ($tmpMH) {
         $MH = $tmpMH;
     }
     // $MHに最大縦幅セット
     if (empty($FromImgPath) || empty($ToImgPath)) {
         return array(0, '出力元画像パス、または出力先フォルダが指定されていません。');
     }
     if (!file_exists($FromImgPath)) {
         return array(0, '出力元画像が見つかりません。');
     }
     $size = @GetImageSize($FromImgPath);
     $re_size = $size;
     // 画像の種類が不明 or swf
     if (!$size[2] || $size[2] > 3) {
         return array(0, '画像形式がサポートされていません。');
     }
     //アスペクト比固定処理
     $tmp_w = $size[0] / $MW;
     if ($MH != 0) {
         $tmp_h = $size[1] / $MH;
     }
     if ($tmp_w > 1 || $tmp_h > 1) {
         if ($MH == 0) {
             if ($tmp_w > 1) {
                 $re_size[0] = $MW;
                 $re_size[1] = $size[1] * $MW / $size[0];
             }
         } else {
             if ($tmp_w > $tmp_h) {
                 $re_size[0] = $MW;
                 $re_size[1] = $size[1] * $MW / $size[0];
             } else {
                 $re_size[1] = $MH;
                 $re_size[0] = $size[0] * $MH / $size[1];
             }
         }
     }
     // サムネイル画像ファイル名作成処理
     $tmp = array_pop(explode('/', $FromImgPath));
     // /の一番最後を切り出し
     $FromFileName = array_shift(explode('.', $tmp));
     // .で区切られた部分を切り出し
     $ToFile = $FromFileName;
     // 拡張子以外の部分までを作成
     $ImgNew = imagecreatetruecolor($re_size[0], $re_size[1]);
     switch ($size[2]) {
         case '1':
             //gif形式
             if ($tmp_w <= 1 && $tmp_h <= 1) {
                 if ($newFileName) {
                     $ToFile = $newFileName;
                 } elseif ($ext) {
                     $ToFile .= '.' . $ext;
                 } else {
                     $ToFile .= '.gif';
                 }
                 if (!@copy($FromImgPath, $ToImgPath . $ToFile)) {
                     // エラー処理
                     return array(0, 'ファイルのコピーに失敗しました。');
                 }
                 ImageDestroy($ImgNew);
                 return array(1, $ToFile);
             }
             ImageColorAllocate($ImgNew, 255, 235, 214);
             //背景色
             $black = ImageColorAllocate($ImgNew, 0, 0, 0);
             $red = ImageColorAllocate($ImgNew, 255, 0, 0);
             Imagestring($ImgNew, 4, 5, 5, "GIF {$size['0']}x{$size['1']}", $red);
             ImageRectangle($ImgNew, 0, 0, $re_size[0] - 1, $re_size[1] - 1, $black);
             if ($newFileName) {
                 $ToFile = $newFileName;
             } elseif ($ext) {
                 $ToFile .= '.' . $ext;
             } else {
                 $ToFile .= '.png';
             }
             $TmpPath = $ToImgPath . $ToFile;
             @Imagepng($ImgNew, $TmpPath);
             // 画像が作成されていない場合
             if (!@file_exists($TmpPath)) {
                 return array(0, '画像の出力に失敗しました。');
             }
             ImageDestroy($ImgNew);
             return array(1, $ToFile);
         case '2':
             //jpg形式
             $ImgDefault = ImageCreateFromJpeg($FromImgPath);
             //ImageCopyResized($ImgNew, $ImgDefault, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]);
             if ($re_size[0] != $size[0] || $re_size[0] != $size[0]) {
                 ImageCopyResampled($ImgNew, $ImgDefault, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]);
             }
             GcUtils::gfDebugLog($size);
             GcUtils::gfDebugLog($re_size);
             if ($newFileName) {
                 $ToFile = $newFileName;
             } elseif ($ext) {
                 $ToFile .= '.' . $ext;
             } else {
                 $ToFile .= '.jpg';
             }
             $TmpPath = $ToImgPath . $ToFile;
             @ImageJpeg($ImgNew, $TmpPath);
             // 画像が作成されていない場合
             if (!@file_exists($TmpPath)) {
                 return array(0, "画像の出力に失敗しました。<br>{$ImgNew}<br>{$TmpPath}");
             }
             $RetVal = $ToFile;
             break;
         case '3':
             //png形式
             $ImgDefault = ImageCreateFromPNG($FromImgPath);
             //ImageCopyResized($ImgNew, $ImgDefault, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]);
             ImageCopyResampled($ImgNew, $ImgDefault, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]);
             if ($newFileName) {
                 $ToFile = $newFileName;
             } elseif ($ext) {
                 $ToFile .= '.' . $ext;
             } else {
                 $ToFile .= '.png';
             }
             $TmpPath = $ToImgPath . $ToFile;
             @ImagePNG($ImgNew, $TmpPath);
             // 画像が作成されていない場合
             if (!@file_exists($TmpPath)) {
                 return array(0, '画像の出力に失敗しました。');
             }
             $RetVal = $ToFile;
             break;
     }
     ImageDestroy($ImgDefault);
     ImageDestroy($ImgNew);
     return array(1, $RetVal);
 }
Exemplo n.º 25
0
 private function view_circle()
 {
     $id = $_REQUEST["id"];
     $colname = $_REQUEST["colname"];
     $w = $_REQUEST["w"];
     if (!isset($this->max)) {
         $this->max = $this->MaxNumber($colname);
     }
     $res = mysql_query("SELECT {$colname} FROM {$this->table} WHERE {$this->idname}='{$id}'", $this->conn) or die(mysql_error());
     $data = mysql_fetch_array($res);
     $value = $data[0];
     mysql_free_result($res);
     $maxr = $w / 2;
     $maxopp = pi() * pow($maxr, 2);
     $opp = $maxopp * ($value / $this->max);
     $r = sqrt($opp / pi());
     $width = $r * 2;
     $im = imagecreatetruecolor($w, $w) or die("Cannot Initialize new GD image stream");
     imagealphablending($im, FALSE);
     imagesavealpha($im, TRUE);
     $bg = imagecolorallocatealpha($im, 255, 255, 255, 127);
     imagefill($im, 0, 0, $bg);
     $clr = imagecolorallocatealpha($im, 0, 0, 255, 60);
     imagefilledarc($im, $maxr, $maxr, $width, $width, 0, 360, $clr, IMG_ARC_PIE);
     Header("Content-type: image/png");
     Imagepng($im);
     ImageDestroy($im);
 }
Exemplo n.º 26
0
 function display($db_object, $common, $user_id, $default, $error_msg, $learning, $get_var)
 {
     //from table
     //setting color
     $config_table = $common->prefix_table("config");
     $color_qry = "select admin_color,rater1_color,rater2_color,rater3_color,self_color,\n\t\t\t\toverall_color from {$config_table} where id='1'";
     $res = $db_object->get_a_line($color_qry);
     $ad_col = $res['admin_color'];
     $rt1_col = $res['rater1_color'];
     $rt2_col = $res['rater2_color'];
     $rt3_col = $res['rater3_color'];
     $self_col = $res['self_color'];
     $over_col = $res['overall_color'];
     $admin = $common->split_color($db_object, $ad_col);
     $rt1 = $common->split_color($db_object, $rt1_col);
     $rt2 = $common->split_color($db_object, $rt2_col);
     $rt3 = $common->split_color($db_object, $rt3_col);
     $slf = $common->split_color($db_object, $self_col);
     $ovr = $common->split_color($db_object, $over_col);
     //for raters
     //rater1
     $col1_1 = "0x{$rt1['0']}";
     $col1_2 = "0x{$rt1['1']}";
     $col1_3 = "0x{$rt1['2']}";
     $col1_1 = hexdec($col1_1);
     $col1_2 = hexdec($col1_2);
     $col1_3 = hexdec($col1_3);
     //rater2
     $col2_1 = "0x{$rt2['0']}";
     $col2_2 = "0x{$rt2['1']}";
     $col2_3 = "0x{$rt2['2']}";
     $col2_1 = hexdec($col2_1);
     $col2_2 = hexdec($col2_2);
     $col2_3 = hexdec($col2_3);
     //rater3
     $col3_1 = "0x{$rt3['0']}";
     $col3_2 = "0x{$rt3['1']}";
     $col3_3 = "0x{$rt3['2']}";
     $col3_1 = hexdec($col3_1);
     $col3_2 = hexdec($col3_2);
     $col3_3 = hexdec($col3_3);
     //self
     $col4_1 = "0x{$slf['0']}";
     $col4_2 = "0x{$slf['1']}";
     $col4_3 = "0x{$slf['2']}";
     $col4_1 = hexdec($col4_1);
     $col4_2 = hexdec($col4_2);
     $col4_3 = hexdec($col4_3);
     //for admin
     $col5_1 = "0x{$admin['0']}";
     $col5_2 = "0x{$admin['1']}";
     $col5_3 = "0x{$admin['2']}";
     $col5_1 = hexdec($col5_1);
     $col5_2 = hexdec($col5_2);
     $col5_3 = hexdec($col5_3);
     //overall
     $col6_1 = "0x{$ovr['0']}";
     $col6_2 = "0x{$ovr['1']}";
     $col6_3 = "0x{$ovr['2']}";
     $col6_1 = hexdec($col6_1);
     $col6_2 = hexdec($col6_2);
     $col6_3 = hexdec($col6_3);
     //color setting ends
     $width = 340;
     $height = 270;
     $labelfont = 2;
     $labelfont1 = 1;
     $labeltitlefont = '3';
     $image = ImageCreate($width, $height);
     while (list($kk, $vv) = @each($get_var)) {
         ${$kk} = $vv;
     }
     $bgcolor = imagecolorallocate($image, 0xff, 0xff, 0xff);
     $border = ImageColorAllocate($image, 0, 0, 0);
     $rater1 = imagecolorallocate($image, $col1_1, $col1_2, $col1_3);
     $rater2 = imagecolorallocate($image, $col2_1, $col2_2, $col2_3);
     $rater3 = imagecolorallocate($image, $col3_1, $col3_2, $col3_3);
     $self = imagecolorallocate($image, $col4_1, $col4_2, $col4_3);
     $boss = imagecolorallocate($image, $col5_1, $col5_2, $col5_3);
     $over = imagecolorallocate($image, $col6_1, $col6_2, $col6_3);
     /* to check 
     		$fromdate="2003-11-13";
     		$todate="2003-11-22";
     		$ratername="emp,bharathi,admin,karthik";
     		$raterval="0,1,2:1,0:1,0,2:1,2,0,2";
     		$date="2003-11-13,2003-11-17,2003-11-22:2003-11-13,2003-11-22:2003-11-13,2003-11-20,2003-11-22:2003-11-13,2003-11-15,2003-11-19,2003-11-22";
     		*/
     $fdate = $fromdate;
     $tdate = $todate;
     if ($ratername != "") {
         $rname = @split(",", $ratername);
     }
     $rt_val = @split(":", $raterval);
     $rt_date = @split(":", $date);
     $from = @split("-", $fdate);
     $to = @split("-", $tdate);
     $dt1 = mktime(0, 0, 0, $to[1], $to[2], $to[0]);
     $dt2 = mktime(0, 0, 0, $from[1], $from[2], $from[0]);
     $dt3 = $dt1 - $dt2;
     $daydiff = $dt3 / 60 / 60 / 24;
     $avg_array = @split(",", $avgrating);
     $ch_name = @split(":", $combine);
     $combine_array = array();
     for ($na = 0; $na < count($ch_name); $na++) {
         $cl_name = $ch_name[$na];
         $sp_clname = @split("=", $cl_name);
         $ky = trim($sp_clname[0]);
         $vl = $sp_clname[1];
         $combine_array[$ky] = $vl;
     }
     //na loop
     $days = $error_msg['cDays'] . " {$fdate} " . $error_msg['cTo'] . " {$tdate}";
     ImageRectangle($image, 65, 24, 315, 180, $border);
     ImageString($image, $labelfont, 15, 19, $error_msg['cExceeds'], $border);
     ImageString($image, $labelfont, 40, 94, $error_msg['cMet'], $border);
     ImageString($image, $labelfont, 5, 170, $error_msg['cFellshort'], $border);
     ImageString($image, $labeltitlefont, 70, 182, "{$days}", $border);
     Imageline($image, 65, 102, 315, 102, $border);
     ImageStringUp($image, $labeltitlefont, 15, 140, $error_msg['cExpectation'], $border);
     $x1 = 65;
     //$y1 = 180;
     $startx_val = $x1;
     $starty_val = 180;
     //$x2 = 130;
     //$y2 = 95;
     $min = 63;
     $max = 311;
     $tot = $max - $min;
     $count = $daydiff;
     $interval = @($tot / $count);
     $interval = sprintf("%01.0f", $interval);
     ImageString($image, $labelfont, 15, 24, "", $border);
     for ($j = 0; $j <= $count; $j++) {
         if ($min <= $max) {
             ImageString($image, $labelfont1, $min, 176, "|", $border);
         }
         $min = $min + $interval;
     }
     $d_array = array();
     $inc = 50;
     $im_dates = split("-", $fdate);
     //ImageString($image, $labelfont, 50,80,"$im_dates[2]", $border);
     //to calculate the x2 value.
     $odd = array("01", "03", "05", "07", "08", "10", "12");
     //Odd months
     $even = array("04", "06", "09", "11");
     //even months
     //ImageString($image, $labelfont, 50,80,"$rt_date[0]", $border);
     for ($f = 0; $f < count($rt_date); $f++) {
         $date_arr = $rt_date[$f];
         $date_array = @split(",", $date_arr);
         for ($d = 0; $d < count($date_array); $d++) {
             $start_date = $im_dates[2];
             $ar = $date_array[$d];
             $im_da = split("-", $ar);
             $dte = $im_da[2];
             $m = $im_da[1];
             for ($c = 0; $c <= $daydiff; $c++) {
                 if ($dte == $start_date) {
                     $dt_array[] = $c;
                 }
                 $start_date = $start_date + 1;
                 if (in_array($m, $odd)) {
                     if ($start_date == 32) {
                         $start_date = 1;
                         $m = $m + 1;
                         if ($m == 13) {
                             $m = 1;
                         }
                     }
                 } elseif (in_array($m, $even)) {
                     if ($start_date == 31) {
                         $start_date = 1;
                         $m = $m + 1;
                         if ($m == 13) {
                             $m = 1;
                         }
                     }
                 } else {
                     if ($start_date == 29) {
                         $start_date = 1;
                         $m = $m + 1;
                     }
                 }
             }
         }
         //d loop
     }
     //f loop
     $d_inc = 0;
     $color1 = $red;
     $color2 = $blue;
     $color3 = $green;
     $color4 = $rose;
     $n_inc = 200;
     for ($i = 0; $i < count($rname); $i++) {
         $name = $rname[$i];
         $avg = $avg_array[$i];
         $rtval = $rt_val[$i];
         $rtdate = $rt_date[$i];
         $rval = @split(",", $rtval);
         $rdate = @split(",", $rtdate);
         $pl = $i + 1;
         $colour = $combine_array[$name];
         $colour = trim($colour);
         $color = ${$colour};
         for ($j = 0; $j < count($rval) - 1; $j++) {
             $ful = $rval[$j];
             $dt_val = $dt_array[$d_inc];
             $dt_val1 = $dt_array[$d_inc + 1];
             //echo $d_inc.($d_inc + 1)."<br>";
             //echo "$dt_val $dt_val1<br>";
             $y1 = $starty_val - 78 * $ful;
             $x1 = $startx_val + $interval * $dt_val;
             //cal using No of Days
             $x2 = $startx_val + $interval * $dt_val1;
             $ful2 = $rval[$j + 1];
             $y2 = $starty_val - 78 * $ful2;
             ImageLine($image, $x1, $y1, $x2, $y2, $color);
             //ImageString($image, $labelfont1,80,$inc,"$ful" ,$col);
             $inc = $inc + 10;
             $x1 = $x2;
             //$y1 = $y2;
             $nor = 1;
             $ct = count($rval) - 1;
             if ($j == $ct - 1) {
                 $nor = $nor + 1;
             }
             $d_inc = $d_inc + $nor;
         }
         //j loop
         ImageString($image, $labelfont1, 130, $n_inc, "{$colour} {$name}  {$error_msg['cAvg']}={$avg}", $color);
         $n_inc += 10;
     }
     // i loop
     if ($overall != "") {
         ImageString($image, $labelfont1, 130, 250, "{$error_msg['cOverallavg']} = {$overall}", $over);
     }
     header("Content-type: image/png");
     Imagepng($image);
     ImageDestroy($image);
 }
Exemplo n.º 27
0
 public function createBarCode($image_type = 'jpg', $file_name = null)
 {
     $this->parseCode();
     //新建一个调色板
     $this->image = ImageCreate($this->width + 2 * $this->quiet_zone, $this->heith + $this->font_height);
     $this->bgcolor = imagecolorallocate($this->image, $this->bgcolor >> 16, $this->bgcolor >> 8 & 0xff, $this->bgcolor & 0xff);
     $this->color = imagecolorallocate($this->image, $this->color >> 16, $this->color >> 8 & 0xff, $this->color & 0xff);
     ImageFilledRectangle($this->image, 0, 0, $this->width + 2 * $this->quiet_zone, $this->heith + $this->font_height, $this->bgcolor);
     $sx = $this->quiet_zone;
     //$sy = $this->font_height -1;
     $sy = 0;
     $fw = 10;
     //編號為2或3的字體的寬度為10,為4或5的字體寬度為11
     if ($this->font_type > 3) {
         $sy++;
         $fw = 11;
     }
     $ex = 0;
     //$ey = $this->heith + $this->font_height - 2;
     $ey = $this->heith;
     for ($i = 0; $i < strlen($this->bin_code); $i++) {
         $ex = $sx + $this->unit_width * (int) $this->bin_code[$i] - 1;
         if ($i % 2 == 0) {
             ImageFilledRectangle($this->image, $sx, $sy, $ex, $ey, $this->color);
         }
         $sx = $ex + 1;
     }
     $t_num = strlen($this->text);
     $t_x = $this->width / $t_num;
     $t_sx = ($t_x - $fw) / 2;
     //目的为了使文字居中平均分布
     for ($i = 0; $i < $t_num; $i++) {
         imagechar($this->image, $this->font_type, 6 * $this->unit_width + $t_sx + $i * $t_x, $this->heith, $this->text[$i], $this->color);
     }
     if (!$file_name) {
         header("Content-Type: image/" . $image_type);
     }
     switch ($image_type) {
         case 'jpg':
         case 'jpeg':
             return Imagejpeg($this->image, $file_name);
             break;
         case 'png':
             Imagepng($this->image, $file_name);
             break;
         case 'gif':
             break;
             Imagegif($this->image, $file_name);
         default:
             Imagepng($this->image, $file_name);
             break;
     }
 }
Exemplo n.º 28
0
 function Novo()
 {
     global $HTTP_POST_FILES;
     if (!empty($HTTP_POST_FILES['foto']['name'])) {
         $fotoOriginal = "tmp/" . $HTTP_POST_FILES['foto']['name'];
         if (file_exists($fotoOriginal)) {
             unlink($fotoOriginal);
         }
         copy($HTTP_POST_FILES['foto']['tmp_name'], $fotoOriginal);
         list($imagewidth, $imageheight, $img_type) = getImageSize($fotoOriginal);
         $src_img_original = "";
         $fim_largura = $imagewidth;
         $fim_altura = $imageheight;
         $extensao = $img_type == "2" ? ".jpg" : ($img_type == "3" ? ".png" : "");
         $nome_do_arquivo = date('Y-m-d-h-i') . "-" . substr(md5($fotoOriginal), 0, 10) . $extensao;
         $caminhoDaBig = "fotos/big/{$nome_do_arquivo}";
         $caminhoDaSBig = "fotos/sbig/{$nome_do_arquivo}";
         if ($imagewidth > 700 && $imageheight < $imagewidth) {
             $new_w = 500;
             $ratio = $imagewidth / $new_w;
             $new_h = ceil($imageheight / $ratio);
             if (!file_exists($caminhoDaBig)) {
                 if ($img_type == "2") {
                     $src_img_original = imagecreatefromjpeg($fotoOriginal);
                     $dst_img = imagecreatetruecolor($new_w, $new_h);
                     imagecopyresized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img_original), imagesy($src_img_original));
                     imagejpeg($dst_img, $caminhoDaBig);
                 } else {
                     if ($img_type == "3") {
                         $src_img_original = @ImageCreateFrompng($fotoOriginal);
                         $dst_img = @imagecreatetruecolor($new_w, $new_h);
                         ImageCopyResized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, ImageSX($src_img_original), ImageSY($src_img_original));
                         Imagepng($dst_img, $caminhoDaBig);
                     }
                 }
             }
         } elseif ($imagewidth > 400 && $imageheight > $imagewidth) {
             $new_w = 400;
             $ratio = $imagewidth / $new_w;
             $new_h = ceil($imageheight / $ratio);
             $fim_largura = $new_w;
             $fim_altura = $new_h;
             if (!file_exists($caminhoDaBig)) {
                 if ($img_type == "2") {
                     $src_img_original = @imagecreatefromjpeg($fotoOriginal);
                     $dst_img = @imagecreatetruecolor($new_w, $new_h);
                     imagecopyresized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img_original), imagesy($src_img_original));
                     imagejpeg($dst_img, $caminhoDaBig);
                 } else {
                     if ($img_type == "3") {
                         $src_img_original = @ImageCreateFrompng($fotoOriginal);
                         $dst_img = @imagecreatetruecolor($new_w, $new_h);
                         ImageCopyResized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, ImageSX($src_img_original), ImageSY($src_img_original));
                         Imagepng($dst_img, $caminhoDaBig);
                     }
                 }
             }
         } else {
             if (!file_exists($caminhoDaBig)) {
                 copy($fotoOriginal, $caminhoDaBig);
                 if ($img_type == "2") {
                     $src_img_original = @imagecreatefromjpeg($fotoOriginal);
                 } else {
                     if ($img_type == "3") {
                         $src_img_original = @imagecreatefrompng($fotoOriginal);
                     }
                 }
             }
         }
         $new_w = 100;
         $ratio = $imagewidth / $new_w;
         $new_h = round($imageheight / $ratio);
         $caminhoDaSmall = "fotos/small/{$nome_do_arquivo}";
         if (!file_exists($caminhoDaSmall)) {
             if ($img_type == "2") {
                 $dst_img = @imagecreatetruecolor($new_w, $new_h);
                 @imagecopyresized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img_original), imagesy($src_img_original));
                 @imagejpeg($dst_img, $caminhoDaSmall);
             } else {
                 if ($img_type == "3") {
                     $dst_img = @imagecreatetruecolor($new_w, $new_h);
                     @imageCopyResized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, ImageSX($src_img_original), imageSY($src_img_original));
                     @imagepng($dst_img, $caminhoDaSmall);
                 }
             }
         }
         copy($fotoOriginal, $caminhoDaSBig);
         if (!(file_exists($fotoOriginal) && file_exists($caminhoDaSmall) && file_exists($caminhoDaBig))) {
             die("<center><br>Um erro ocorreu ao inserir a foto.<br>Por favor tente novamente.</center>");
         }
     } else {
         return false;
     }
     @session_start();
     $this->id_pessoa = @$_SESSION['id_pessoa'];
     session_write_close();
     $this->data_foto = str_replace("%2F", "/", $this->data_foto);
     $db = new clsBanco();
     $db->Consulta("INSERT INTO foto_portal ( nm_credito, ref_cod_foto_secao, ref_ref_cod_pessoa_fj, data_foto, titulo, descricao, caminho, altura, largura ) VALUES ( '{$this->nm_credito}', '1',  {$this->id_pessoa}, now(), '{$this->titulo}', '{$this->descricao}', '{$nome_do_arquivo}', {$fim_largura}, {$fim_altura} )");
     echo "<script>document.location='fotos_lst.php';</script>";
     return true;
 }
Exemplo n.º 29
0
 function _output_image($destination_file, $image_type, $image)
 {
     //if destination file is empty  image will be output to browser
     // right now $image_type can be JPEG or PNG
     global $ERR;
     $destination_file = trim($destination_file);
     $res = false;
     if ($image) {
         switch ($image_type) {
             case 'JPEG':
             case 'JPG':
                 $res = ImageJpeg($image, $destination_file, $this->jpeg_quality);
                 break;
             case 'PNG':
                 $res = Imagepng($image, $destination_file);
                 break;
             default:
                 $this->error($ERR["UNKNOWN_OUTPUT_FORMAT"] . " {$image_type}");
                 break;
         }
     } else {
         $this->error($ERR["NO_IMAGE_FOR_OUTPUT"]);
     }
     if (!$res) {
         $this->error($ERR["UNABLE_TO_OUTPUT"] . " {$destination_file}");
     }
     return $res;
 }
Exemplo n.º 30
0
 function imageMix($mix)
 {
     global $engine_path, $ImageTrimX, $ImageTrimY;
     $source = $this->image;
     $imType = $this->type;
     if (!$imType || $imType == "jpeg" || $imType == "pjpeg") {
         $srcImage = ImageCreateFromJPEG($source);
     } elseif ($imType == "gif") {
         $srcImage = LoadGif($source);
     } else {
         $srcImage = ImageCreateFromPNG($source);
     }
     if ($mix) {
         $srcImage = $this->mix($srcImage, $mix);
     }
     $name = $engine_path . "tmp/" . "mix" . $this->name;
     if (!file_exists($engine_path . "tmp/")) {
         mkdir_r($engine_path . "tmp/");
     }
     if ($imType == "jpeg" || $imType == "pjpeg") {
         Imagejpeg($srcImage, $name);
     } elseif ($imType == "gif") {
         Imagegif($srcImage, $name);
     } else {
         Imagepng($srcImage, $name);
     }
     $file['tmp_name'] = $name;
     ImageDestroy($srcImage);
     return $file;
 }