/* Classname:imagehandler
* FILENAME:IMAGEHANDLER.PHPCLS
* Author:tony Don
* date:2008-03-27
* @Copyright txdnet.com
* Function:handler Images
*/
Class ImageHandler
{
var $dst _img;//target file
var $h _src; Picture resource handle
var $h _dst;//New Figure handle
var $h _mask;//Watermark Handle
var $img _create_quality = 100;//picture Generation quality
var $img _display_quality = 80;//picture display quality, default is 75
var $img _scale = 0;//Picture zoom ratio
var $src _w = 0;//original width
var $src _h = 0;//original height
var $dst _w = 0;//total width of new chart
var $dst _h = total height of 0;//new figure
var $fill _w;//Fill graphic width
var $fill _h;//Fill Graphics high
var $copy _w;//Copy Graphics width
var $copy _h;//Copy Graphics high
var $src _x = 0;//Original Draw starting Horizontal
var $src _y = 0;//Original map drawing start ordinate
The starting horizontal axis of Var $start _x;//New Drawing
var $start _y;//New Figure drawing start ordinate
var $mask _word;//Watermark Text
var $mask _img;//Watermark Image
var $mask _pos_x = 0;//Watermark Horizontal
var $mask _pos_y = 0;//Watermark Ordinate
var $mask _offset_x = 5;//watermark Lateral offset
var $mask _offset_y = 5;//Watermark Vertical Offset
var $font _w;//Watermark Font Width
var $font _h;//watermark Font Height
var $mask _w;//Watermark Width
var $mask _h;//High watermark
var $mask _font_color = "#000000";//Watermark text color
var $mask _font = 5;//Watermark Font
var $font _size;//Size
var $mask _position = 0;//Watermark Location
var $mask _img_pct = 50;//picture Merge degree, the higher the value, the lower the merge program
var $mask _txt_pct = 50;//text merge degree, the lower the value, the less the merge program
var $img _border_size = 0;//picture Border size
var $img _border_color;//picture Border color
var $_flip_x=0;//horizontal rollover times
var $_flip_y=0;//vertical Rollover times
var $cut _type=0;//cut or shrink type
var $img _type;//File type
The file type definition, and indicates the function of the output picture
var $all _type = Array (
"jpg" = = Array ("Output" = "imagejpeg"),
"gif" = = Array ("Output" = "imagegif"),
"png" = = Array ("Output" = "imagepng"),
"Wbmp" = = Array ("Output" = "image2wbmp"),
"JPEG" = = Array ("Output" = "imagejpeg"));
/**
* Constructor function
*/
function ImageHandler ()
{
$this->mask_font_color = "#ffffff";
$this->font = 2;
$this->font_size = 12;
}
/**
* Get the width of the picture
*/
function Getimgwidth ($SRC)
{
Return Imagesx ($SRC);
}
/**
* Get pictures of high
*/
function Getimgheight ($SRC)
{
Return Imagesy ($SRC);
}
/**
* Set Picture Generation path
*
* @param string $src _img picture Generation Path
*/
function setsrcimg ($src _img, $img _type=null)
{
if (!file_exists ($src _img))
{
Die ("Picture does not exist");
}
if (!empty ($img _type))
{
$this->img_type = $img _type;
}
Else
{
$this->img_type = $this->_getimgtype ($src _img);
}
$this->_checkvalid ($this->img_type);
file_get_contents function requires PHP version >4.3.0
$SRC = ";
if (function_exists ("file_get_contents"))
{
$SRC = file_get_contents ($src _img);
}
Else
{
$handle = fopen ($src _img, "R");
while (!feof ($handle))
{
$src. = Fgets ($FD, 4096);
}
Fclose ($handle);
}
if (empty ($SRC))
{
Die ("The picture source is empty");
}
$this->h_src = @ImageCreateFromString ($SRC);
$this->src_w = $this->getimgwidth ($this->h_src);
$this->src_h = $this->getimgheight ($this->h_src);
}
/**
* Set Picture Generation path
*
* @param string $dst _img picture Generation Path
*/
function setdstimg ($DST _img)
{
$arr = explode ('/', $dst _img);
$last = Array_pop ($arr);
$path = implode ('/', $arr);
$this->_mkdirs ($path);
$this->dst_img = $dst _img;
}
/**
* Set the display quality of the picture
*
* @param string $n quality
*/
function Setimgdisplayquality ($n)
{
$this->img_display_quality = (int) $n;
}
/**
* Set the build quality of the picture
*
* @param string $n quality
*/
function Setimgcreatequality ($n)
{
$this->img_create_quality = (int) $n;
}
/**
* Set Text watermark
*
* @param string $word watermark Text
* @param integer $font watermark Font
* @param string $color watermark Font Color
*/
function Setmaskword ($word)
{
$this->mask_word. = $word;
}
/**
* Set Font Color
*
* @param string $color font Color
*/
function Setmaskfontcolor ($color = "#ffffff")
{
$this->mask_font_color = $color;
}
?>
http://www.bkjia.com/PHPjc/445073.html www.bkjia.com true http://www.bkjia.com/PHPjc/445073.html techarticle PHP/* classname:imagehandler * FILENAME:IMAGEHANDLER.PHPCLS * author:tony Don * date:2008-03-27 * @Copyright TXD net.com * Function:handler Images */class ImageHandler {var ...