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);
  
} 
  |