| Server IP : 172.67.216.113 / Your IP : 104.23.243.33 [ Web Server : Apache System : Linux cpanel01wh.bkk1.cloud.z.com 2.6.32-954.3.5.lve1.4.59.el6.x86_64 #1 SMP Thu Dec 6 05:11:00 EST 2018 x86_64 User : cp648411 ( 1354) PHP Version : 7.2.34 Disable Function : NONE Domains : 0 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home2/cp648411/public_html/kainumber.com/taro/ |
Upload File : |
<?php
//By aPinan
//GPL License
//Have fun..!
function watermarkImage ($SourceFile, $WaterMarkText,$WaterMarkName,$WaterMarkTextDe, $DestinationFile) {
putenv('GDFONTPATH=' . realpath('.'));
list($width, $height) = getimagesize($SourceFile);
$height = 315;
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($SourceFile);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width, $height);
$black = imagecolorallocate($image_p, 0, 0, 0);//กำหนดสีดำ
$rad = imagecolorallocate($image_p, 255, 0, 0);//กำหนดสี
// $font = 'THA0006.ttf';//กำหนดชื่อฟอนต์
$font = 'eak_khunwai.ttf';
$font_size = 56; //กำหนดขนาดฟอนต์
imagettftext($image_p, $font_size, 0, 150, 80, $black, $font, $WaterMarkText);
imagettftext($image_p, 16, 0,200, 110, $rad, $font, $WaterMarkName);
$WaterMarkTextDe = strip_tags($WaterMarkTextDe);
$WaterMarkTextDe = str_replace(" ", " ", $WaterMarkTextDe);
$WaterMarkTextDe = str_replace("•", " ", $WaterMarkTextDe);
$WaterMarkTextDe = str_replace("…", " ", $WaterMarkTextDe);
$lines = explode('|', wordwrap($WaterMarkTextDe, 100, '|'));
$y = 150;
foreach ($lines as $line)
{
//$line = iconv_substr($line,0,150,'UTF-8');
imagettftext($image_p, 24, 0, 90, $y, $black, $font, $line);
// Increment Y so the next line is below the previous line
$y += 25;
}
//imagettftext($image_p, 18, 0, 50, 120, $black, $font, $WaterMarkTextDe);
//อธิบาย imagettftext($image_p,ขนาดฟอนต์,องศ์ษา,แนวนอน,แนวตั้ง,สี,ชื่อฟอร์ตที่ใช้,ข้อความ);
if ($DestinationFile<>'') {
imagejpeg ($image_p, $DestinationFile, 100);
} else {
header('Content-Type: image/jpeg');
imagejpeg($image_p, null, 100);
};
imagedestroy($image);
imagedestroy($image_p);
};
?>