PHP Image Operation class This program can obtain the image size, format and other information, but also to the image of the thumbnail processing and image watermark function Oh.
PHP Tutorial Image Manipulation Class
This section of the program can obtain image size, format and other information, but also to image thumbnail processing and to the image watermark function Oh.
Class image{
public $filename;
Private $info;
Private $im;
Structure
Public function __construct ($filename) {
$this->filename = $filename;
$this->info = @getimagesize ($filename);
if ($this->info[2]>3) {echo] only supports GIF, JPEG, PNG format. "; exit;}
}
Gta5-In
Public Function Imgload () {
Switch ($this->info[2]) {
Case 1:
$this->im= @imagecreatefromgif ($this->filename);
Break
Case 2:
$this->im= @imagecreatefromjpeg ($this->filename);
Break
Case 3:
$this->im= @imagecreatefrompng ($this->filename);
Break
}
}
//Save
Public Function Imagesave ($img, $savename, $inf) {
Switch ($inf) {
Case 1:
Imagegif ($img, $savename );;
break;
Case 2:
imagejpeg ($img, $savename);;
break;
Case 3:
Imagepng ($img, $savename);;
break;
}
}
Filter
Public Function filter ($arg =1, $savename = ") {
$this->imgload ();
if ($savename = = ") $savename = ' f_ '. $this->filename;
$ok =false;
Switch ($arg) {
Case 1:
ImageFilter ($this->im,img_filter_negate);//Inverse color
$ok =true;
Break
Case 2:
ImageFilter ($this->im,img_filter_grayscale); Black
$ok =true;
Break
Case 3:
ImageFilter ($this->im,img_filter_emboss);//Emboss
$ok =true;
Break
Case 4:
ImageFilter ($this->im,img_filter_gaussian_blur); Gaussian Blur
$ok =true;
Break
Case 5:
ImageFilter ($this->im,img_filter_brightness,50); Brightness 50
$ok =true;
Break
Case 6:
ImageFilter ($this->im,img_filter_contrast,-50); Contrast Ratio-50
$ok =true;
Break
}
if ($ok) {
$this->imagesave ($this->im, $savename, $this->info[2]); Write a file
Imagedestroy ($this->im);
return 1;
}else{
Imagedestroy ($this->im);
return 0;}
}
1 2 3
http://www.bkjia.com/PHPjc/633038.html www.bkjia.com true http://www.bkjia.com/PHPjc/633038.html techarticle PHP Image Operation class This program can obtain the image size, format and other information, but also to the image of the thumbnail processing and image watermark function Oh. PHP Tutorial image Operation Class ...