/**
* GD庫 圖片縮略圖
*/
/*$image = imagecreatefromjpeg("1.jpg");var_dump($image);exit;
$width = imagesx($image);
$height = imagesy($image);
$thumb_width = $width *0.5;
$thumb_height = $height *0.5;
$thumb = imagecreatetruecolor($thumb_width,$thumb_height);//建立一個原圖一半大小的畫布
imagecopyresampled($thumb,$image,0,0,0,0,$thumb_width,$thumb_height,$width,$height);
imagejpeg($thumb,"1_thumb.jpg",100);//將縮略圖保存到文件,第三個參數是質量
imagedestroy($thumb);//清楚佔用內存
//圖像輸出到瀏覽器
header("Content-type: image/jpeg");
imagejpeg($image);*/
/**
* 圖片水印
*/
$image =imagecreatefromjpeg("1.jpg");
$pink = ImageColorAllocate($image,120,180,250);//填充顏色
$font_file ="Candara.ttf";
$str ="php >_< ";
//$str =mb_convert_encoding($str,"UTF-8","GBK");
$str = iconv("GBK", "UTF-8", $str);
imagettftext($image,25,10,100,200,$pink,$font_file,$str);//設置字體顏色
imagejpeg($image,"1_text.jpg",100);//將帶有文字的圖片保存到文件
imagedestroy($image);
?>
<meta http-equiv="content-Type" content="text/html; charset=utf8"/>
<!--<p>原圖</p>
<img src="1.jpg" />
<p>縮略圖</p>
<img src="1_thumb.jpg" />-->
<p>合成圖:</p>
<img src="1_text.jpg" />php