電腦滑鼠細菌數
是馬桶400倍
搬家專業居家清潔
免費到府估價,清潔養護馬上搞定

首頁  •  j2h 論壇 • 程式設計討論     • 

[php] GD JPEG 自動縮圖 , 插入文字 , 插入浮水印

房東:小橋
發表時間:2012-12-27
[檢舉]


function ecstart_convert_jpeg($src_file,$dst_file,$text_type,$text_image,$watermark_type,$watermark_image,$pic_width,$pic_height){



//$src_file 來源圖片路徑

//$dst_file 存檔圖片路徑

//$text_type 是否插入文字

//$text_image 插入的文字內容

//$watermark_type 是否插入浮水印

//$watermark_image 圖水印圖片路徑

//$pic_width 存檔圖片寬度

//$pic_height 存檔圖片高度

$image = imagecreatefromjpeg($src_file) ;

$s_width = imagesx($image);

$s_height = imagesy($image);





// 縮圖大小

$thumb = imagecreatetruecolor($pic_width, $pic_height);

// 自動縮圖

imagecopyresized($thumb, $image, 0, 0, 0, 0, $pic_width, $pic_height, $s_width, $s_height);

//imagejpeg($thumb,"/tmp/tmpfile.jpg","100");

//$thumbimage = imagecreatefromjpeg("/tmp/tmpfile.jpg") ;





// 取得寬度

$i_width = imagesx($thumb);

$i_height = imagesy($thumb);



//imagejpeg($image,"/home/www/ecstart.com/public_html/cart/test.jpg","100");

//imagejpeg($image);



// 計算 插入文字出現位置

$ywpos = $i_height - 35 ;

// 設定 插入文字

$textcolor = imagecolorallocate($thumb, 250, 250, 250);



// 插入文字

if($text_type == "Y"){

imagestring($thumb, 5, 25, $ywpos, $text_image, $textcolor);

}

// 載入浮水印圖

$w_image = imagecreatefromjpeg($watermark_image) ;

// 取出浮水印圖 寬 與 高

$w_width = imagesx($w_image);

$w_height = imagesy($w_image);

// 計算 浮水印出現位置

$xpos = $i_width - $w_width -20 ;

$ypos = $i_height - $w_height-20 ;



//結合浮水印

if($watermark_type == "Y"){

imagecopy($thumb,$w_image,$xpos,$ypos,0,0,$w_width,$w_height);

}



imagejpeg($thumb,$dst_file,"100");





imagedestroy($thumb);

imagedestroy($image);

imagedestroy($w_image);

}





  • 贊助網站       

    廣利不動產-板橋在地生根最實在--新板特區指名度最高、值得您信賴的好房仲
    完整房訊,房屋、店面熱門精選物件,廣利不動產 優質仲介,房屋租賃、買賣資訊透明,交易真安心!
    廣利不動產-新板特區指名度最高、值得您信賴的好房仲
    您的托付,廣利用心為您服務



  •  共 0 人回應

    姓名:
    佈告內容: