1 imageCreateFrom* image loading function
//For images with different suffixes
imagecreatefromgif
imagecreatefromjpeg
imagecreatefrompng
imagecreatefromwbmp
imagecreatefromstring
Use format: imagecreatefromgif("jjj.gif ");
Two imagecopy image merging functions
imagecopy(destimage,simage,int x,int y,int src_x,int src_y,int src_w,int src_h);
destimage --- original image (large Picture)
simage ---logo picture (small picture)
x ---coordinates of original image
y ---
src_x ---coordinates of logo image
src_y -- -
src_w ---Width of logo image
src_h ---Height of logo image
Three imagecopyresized image cutting function
imagecopyresized(resource dst_image,resource src_image,int dst_x,int dst_y,int src_x,int src_y,int dst_w,int dst_h,int src_w,int src_h);
dst_image ---original true color picture
src_image ---original picture
dst_x ---from what The starting point is usually 0
dst_y --- usually 0
src_x --- where to start cutting, usually 0
src_y --- usually 0
dst_w --- create a new picture The width and height of
dst_h ---
src_w --- The width and height of the original image
src_h ---
Example question:
image.php
Copy code The code is as follows:
/*
* This php file implements image watermarking and generation of abbreviations Thumbnail function
*
*/
//This does not include the upload function. First, put the image in the root directory of the project
//Import and parse the image
$image = "img.jpg ";
$img=GetImageSize($image);
//Determine the suffix name of the image
switch($img[2]){
case 1:
$im=ImageCreateFromGIF( $image);
break;
case 2:
$im=ImageCreateFromJPEG($image);
break;
case 3:
$im=ImageCreateFromPNG($image);
break;
}
//Parse the picture
$logo = "pic.jpg";
$pic=GetImageSize($logo);
switch($pic[2] ){
case 1:
$im_pic=ImageCreateFromGIF($logo);
break;
case 2:
$im_pic=ImageCreateFromJPEG($logo);
break;
case 3:
$im_pic=ImageCreateFromPNG($logo);
break;
}
//Image synthesis, also making watermarks
imagecopy($im,$im_pic,0,500,0 ,0,100,75);
//Set the color
$fc=imagecolorallocate($im,255,255,255);
//First convert the text into utf-8 format
//$str= iconv("gb2312","utf-8","Hehehe");
//Add Chinese watermark
imagettftext($im,12,0,20,20,$fc,"simkai.ttf" ,"My QQ: 260954520");
//Create an original true color image
$new_img=imagecreatetruecolor(50,40);
//Cut the image
imagecopyresized($new_img, $im,0,0,0,0,50,40,$img[0],$img[1]);
//Output image
header("Content-type:image/jpeg") ;
//After cutting the small image, you can use judgment to generate a small image as shown below
imagejpeg($new_img);
//Generate a watermarked image
/*
if(imagejpeg($im,"new image.jpg")){
echo "Watermark successful";
}
*/
?>
http://www.bkjia.com/PHPjc/320950.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320950.htmlTechArticleOne imageCreateFrom* image loading function //For different suffix name images imagecreatefromgif imagecreatefromjpeg imagecreatefrompng imagecreatefromwbmp imagecreatefromstring use format.. .