Example #1
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;
 }
Example #2
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;
 }
Example #3
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;
 }
Example #4
0
{
    if ($tb > 15) {
        return 0;
    } elseif ($tb < 0) {
        return 255;
    } else {
        return (15 - $tb) / 15 * 255;
    }
}
header("Content-type: image/gif");
db_connect();
$query = "SELECT * FROM records ORDER BY `id` DESC LIMIT 1";
$result = mysql_query($query) or die("Query failed with error: " . mysql_error());
$row = mysql_fetch_array($result) or die(mysql_error());
$uts_now = time();
$last_read = $row['uts'];
db_disconnect();
$ImLoc = "../images/";
$temp = number_format($row['temp'], 0);
$img = LoadGif("../images/gsbk.gif");
imagefilter($img, IMG_FILTER_COLORIZE, GetRed($temp), GetGreen($temp), GetBlue($temp), GetBlue($temp));
$txt_color = ImageColorAllocate($img, 0, 0, 0);
if ($temp < 10 && $temp > -10) {
    //T_SPAR
    $ulc_start = 12;
} else {
    $ulc_start = 7;
}
ImageString($img, 5, $ulc_start, 8, $temp, $txt_color);
//echo GetRed($temp).", ".GetGreen($temp).", ".GetBlue($temp);
imagegif($img);
Example #5
0
        return 0;
    } elseif ($tg < 15) {
        return ($tg - 0) / 12 * 225;
    } else {
        return (22 - $tg) / 10 * 225;
    }
}
function GetBlue($tb)
{
    if ($tb > 15) {
        return 0;
    } elseif ($tb < 0) {
        return 255;
    } else {
        return (15 - $tb) / 15 * 255;
    }
}
//header("Content-Type: image/gif");
$temp = $_GET['t'];
$img = LoadGif("gsbk.gif");
imagefilter($img, IMG_FILTER_COLORIZE, GetRed($temp), GetGreen($temp), GetBlue($temp), GetBlue($temp));
$txt_color = ImageColorAllocate($img, 0, 0, 0);
if ($temp < 10 && $temp > -10) {
    //T_SPAR
    $ulc_start = 12;
} else {
    $ulc_start = 7;
}
ImageString($img, 5, $ulc_start, 8, $temp, $txt_color);
//echo GetRed($temp).", ".GetGreen($temp).", ".GetBlue($temp);
imagegif($img);
Example #6
0
function createImage($length, $size)
{
    $string_a = array("A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "2", "3", "4", "5", "6", "7", "8", "9");
    $keys = array_rand($string_a, $length);
    $string = "";
    foreach ($keys as $n => $v) {
        $string .= $string_a[$v];
    }
    $number = rand(1, 7);
    $im = LoadGif("../images/security/security_background" . $number . ".gif");
    $colour = imagecolorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
    $font = 'lhandw';
    $angle = rand(-20, 20);
    $fileRand = md5(getIp() . strtolower($string));
    putenv('GDFONTPATH=' . realpath('.'));
    //"GDFONTPATH=".realpath("."));//"..")."/fonts/");
    imagettftext($im, $size, $angle, 30, 35, $colour, $font, $string);
    imagegif($im, $fileRand . ".gif");
    return $fileRand;
}
Example #7
0
function convert_GIF_to_JPG($sFilePath)
{
    $ext = get_extension($sFilePath);
    if ($ext != 'gif' && $ext != '.gif') {
        return $sFilePath;
    }
    $newFileName = str_replace('.gif', '_gif.jpg', $sFilePath);
    $img = LoadGif($sFilePath);
    if (imagejpeg($img, $newFileName)) {
        imagedestroy($img);
        unlink($sFilePath);
        return $newFileName;
    } else {
        imagedestroy($img);
        echo "gif文件:{$sFilePath转jpp失败}<br/>";
        return $sFilePath;
    }
    return $sFilePath;
}