09/10/2018, 23:56
PHP - Chèn text vào hình upload ???
Làm sao để chèn thêm text vào 1 tấm hình khi đã dc upload ....giống mấy trang nó hay chèn thêm logo hoặc link website vào ấy (chống chôm chỉa). Pác nào biết thì share nhá, thx trc
Bài liên quan
Hy vọng giúp ích cho bạn !
<?php
$u = $_GET***91;'u'***93;;
$f = $_GET***91;'f'***93;;
$hinh = "hinhanh/".$u."/$f";
function vietchulenanh($image,$text,$font,$color,$size,$padding_left,$padding_top,$gocquay){
$type = substr($image,-3);
if( eregi( "(***91;0-9a-f***93;{2})(***91;0-9a-f***93;{2})(***91;0-9a-f***93;{2})", $color, $ca ) ){
$red = hexdec( $ca***91;1***93; );
$green = hexdec( $ca***91;2***93; );
$blue = hexdec( $ca***91;3***93; );
}
if($type=="jpg" || $type=="jpeg")
{
header("Content-type: image/pjpeg");
$source = imagecreatefromjpeg($image);
$color = imagecolorallocate($source,$red,$green,$blue);
imagettftext($source,$size,$gocquay,$padding_left,$padding_top,$color,$font,$text);
imagejpeg($source);
}
elseif($type=="gif")
{
header("Content-type: image/gif");
$source = imagecreatefromgif($image);
$color = imagecolorallocate($source,$red,$green,$blue);
imagettftext($source,$size,$gocquay,$padding_left,$padding_top,$color,$font,$text);
imagegif($source);
}
elseif($type=="png")
{
header("Content-type: image/png");
$source = imagecreatefrompng($image);
$color = imagecolorallocate($source,$red,$green,$blue);
imagettftext($source,$size,$gocquay,$padding_left,$padding_top,$color,$font,$text);
imagepng($source);
}
else
{
echo "Dinh dang anh khong hop le : ".$type;
}
}
$size = getimagesize( $hinh );
$aaa = $size***91;1***93;;
$bbb = $aaa-10;
vietchulenanh($hinh,"GIANHON.INFO","VTUBE.TTF","FF0000",30,10,$bbb,0);
?>