$ DP = opendir($ URL);
while($aa = readdir($dp)) {
字體($aa,“xx公司”,’。/aa/');
}
關閉($ DP);
}
函數字體($image,$fonts,$newpath,$position=9,$color=2,$size=16) {
//第壹個參數是圖片。
//第二個參數是要寫入的文本。
//第三個參數是存儲路徑。
//第四個參數是文本顯示的位置(可選)。
//第五個參數是顏色(黑白可選)。
//第六個參數是字體大小(可選)
$ img = imagecreatefromjpeg($ image);
if($color==1) {
$ font color = imagecolorlallocate($ img,33,33,33);
}否則{
$ font color = imagecolorlallocate($ img,255,255,255);
}
$ img _ w = imagesx($ img);
$ img _ h = imagesy($ img);
$box = imagettfbbox($size,0,' STXINGKA。TTF ',$ fonts);
$ box _ w = $ box[2]-$ box[0];
$ box _ h = $ box[7]-$ box[1];
開關(位置){
案例1:
$ x = 10;$ y = 36
打破;
案例二:
$ x =($ img _ w-$ box _ w)/2;$ y = 36
打破;
案例三:
$ x = $ img _ w-$ box _ w-170;$ y = 36
打破;
案例4:
$ x = 10;$ y =($ img _ h-$ box _ h)/2;
打破;
案例5:
$ x =($ img _ w-$ box _ w)/2;$ y =($ img _ h-$ box _ h)/2;
打破;
案例6:
$ x = $ img _ w-$ box _ w-200;$ y =($ img _ h-$ box _ h)/2;
打破;
案例7:
$ x = 20$ y =($ img _ h-$ box _ h)-60;
打破;
案例8:
$ x =($ img _ w-$ box _ w)/2;$ y = $ img _ h-$ box _ h-60;
打破;
案例9:
$ x = $ img _ w-$ box _ w-300;$ y = $ img _ h-$ box _ h-60;
打破;
}
imagettftext($img,30,0,$x,$y,$fontColor,' STXINGKA。TTF ',$ fonts);
//header(' Content-Type:image/jpg ');
imagejpeg($img,$ new path);
}
函數reduce($oldpath,$newpath,$new_w) {
//第壹個參數是原圖的路徑。
//第二個參數是減少圖片的路徑。
//第三個參數是縮小圖片的寬度。
$ old = imagecreatefromjpeg($ old path);//原圖
$ old _ w = imagesx($ old);//獲取原始圖片的寬度
$ old _ h = imagesy($ old);//獲取原圖的高度
$ new _ h = $ old _ h/$ old _ w * $ new _ w;
$ new = imagecreatetruecolor($ new _ w,$ new _ h);//新圖片
imagecopyresampled($new,$old,0,0,0,$new_w,$new_h,$old_w,$ old _ h);
//header(' Content-Type:image/jpg ');
imagejpeg($new,$ new path);
}
函數water($bigpath,$smallpath,$newpath,$position=9) {
//第壹個參數大圖
//第二個參數的小圖片
//第三個參數是新圖片的路徑。
//第四個參數是設置小圖出現的位置。
$ big = imagecreatefromjpeg($ big path);//獲得大圖
$ small = imagecreatefromjpeg($ small path);//獲取小圖
$ small _ w = imagesx($ small);//獲取小圖片的寬度
$ small _ h = imagesy($ small);//獲取小圖片的高度
$ big _ w = imagesx($ big);//獲取小圖片的寬度
$ big _ h = imagesy($ big);//獲取小圖片的寬度
開關(位置){
案例1:$ x = 2;$ y = 2;打破;
情況二:$ x =($ big _ w-$ small _ w)/2;$ y = 0;打破;
案例三:$ x = $ big _ w-$ small _ w;$ y = 0;打破;
情況四:$ x = 0;$ y =($ big _ h-$ small _ h)/2;打破;
情況5:$ x =($ big _ w-$ small _ w)/2;$ y =($ big _ h-$ small _ h)/2;打破;
案例六:$ x = $ big _ w-$ small _ w;$ y =($ big _ h-$ small _ h)/2;打破;
情況7:$ x = 0;$ y = $ big _ h-$ small _ h;打破;
情況8:$ x =($ big _ w-$ small _ w)/2;$ y = $ big _ h-$ small _ h;打破;
案例9:$ x = $ big _ w-$ small _ w-2;$ y = $ big _ h-$ small _ h-2;打破;
}
imagecopymerge($big,$small,$x,$y,0,0,$small_w,$small_h,100);//合並兩張圖片1 >;大圖資源2 & gt小圖資源3,4 >大圖坐標為5,6 >;小圖的坐標7,8 >;小圖9 >的寬度和高度;透明度
//header(" Content-Type:image/jpg ");
imagejpeg($big,$ new path);
}
僅供參考,有興趣可以加761084316。我也是初學者。