惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Microsoft Azure Blog
Microsoft Azure Blog
Cloudbric
Cloudbric
I
InfoQ
V
V2EX
博客园_首页
The Register - Security
The Register - Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
S
Secure Thoughts
Vercel News
Vercel News
Forbes - Security
Forbes - Security
云风的 BLOG
云风的 BLOG
PCI Perspectives
PCI Perspectives
L
LINUX DO - 最新话题
D
DataBreaches.Net
H
Hacker News: Front Page
Application and Cybersecurity Blog
Application and Cybersecurity Blog
B
Blog RSS Feed
A
About on SuperTechFans
N
News and Events Feed by Topic
Apple Machine Learning Research
Apple Machine Learning Research
Help Net Security
Help Net Security
Attack and Defense Labs
Attack and Defense Labs
N
Netflix TechBlog - Medium
Spread Privacy
Spread Privacy
F
Full Disclosure
Recorded Future
Recorded Future
AWS News Blog
AWS News Blog
博客园 - 【当耐特】
The Cloudflare Blog
T
Threatpost
T
Tor Project blog
Google DeepMind News
Google DeepMind News
C
CXSECURITY Database RSS Feed - CXSecurity.com
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
M
MIT News - Artificial intelligence
A
Arctic Wolf
C
Check Point Blog
Stack Overflow Blog
Stack Overflow Blog
T
Threat Research - Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News - Newest:
Hacker News - Newest: "LLM"
WordPress大学
WordPress大学
Cyberwarzone
Cyberwarzone
小众软件
小众软件
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Proofpoint News Feed
Security Latest
Security Latest
The Last Watchdog
The Last Watchdog

博客园 - bigwhiteshark(云飞扬)

linux下svn定时更新项目 Html5 Canvas transform setTransform uv纹理坐标设定与贴图规则 容易答错的JS笔试题 JavaScript严谨模式(Strict Mode) property和attribute的区别 深入理解javascript 中的 delete(转) javascript中的call()和apply()方法的使用 Javascript 异步加载详解(转) Javascript框架的自定义事件(转) array2json() - Convert PHP arrays to JSON 一些Vim使用的小技巧 virtualbox centos安装增强工具和Centos与VirtualBox共享文件夹设置 yum搭建lnmp环境(CentOS6.4) CentOS中文man安装配置 在Linux里设置环境变量的方法(export PATH) 更新CentOS防火墙设置开启80端口访问 centos 6.4 server 安装nginx Centos安装vim
PHP合成图片、生成文字、居中对齐、画线、矩形、三角形、多边形、图片抗锯齿、不失真 高性能源码示例
bigwhiteshark(云飞扬) · 2014-12-11 · via 博客园 - bigwhiteshark(云飞扬)
function generateImg($source, $text1, $text2, $text3, $font = './msyhbd.ttf') {
    $date = '' . date ( 'Ymd' ) . '/';
    $img = $date . md5 ( $source . $text1 . $text2 . $text3 ) . '.jpg';
    if (file_exists ( './' . $img )) {
        return $img;
    }
 
    $main = imagecreatefromjpeg ( $source );
 
    $width = imagesx ( $main );
    $height = imagesy ( $main );
 
    $target = imagecreatetruecolor ( $width, $height );
 
    $white = imagecolorallocate ( $target, 255, 255, 255 );
    imagefill ( $target, 0, 0, $white );
 
    imagecopyresampled ( $target, $main, 0, 0, 0, 0, $width, $height, $width, $height );
 
    $fontSize = 18;//像素字体
    $fontColor = imagecolorallocate ( $target, 255, 0, 0 );//字的RGB颜色
    $fontBox = imagettfbbox($fontSize, 0, $font, $text1);//文字水平居中实质
    imagettftext ( $target, $fontSize, 0, ceil(($width - $fontBox[2]) / 2), 190, $fontColor, $font, $text1 );
 
    $fontBox = imagettfbbox($fontSize, 0, $font, $text2);
    imagettftext ( $target, $fontSize, 0, ceil(($width - $fontBox[2]) / 2), 370, $fontColor, $font, $text2 );
 
    $fontBox = imagettfbbox($fontSize, 0, $font, $text3);
    imagettftext ( $target, $fontSize, 0, ceil(($width - $fontBox[2]) / 2), 560, $fontColor, $font, $text3 );
 
    //imageantialias($target, true);//抗锯齿,有些PHP版本有问题,谨慎使用
 
    imagefilledpolygon ( $target, array (10 + 0, 0 + 142, 0, 12 + 142, 20 + 0, 12 + 142), 3, $fontColor );//画三角形
    imageline($target, 100, 200, 20, 142, $fontColor);//画线
    imagefilledrectangle ( $target, 50, 100, 250, 150, $fontColor );//画矩形
 
    //bof of 合成图片
    $child1 = imagecreatefromjpeg ( 'http://gtms01.alicdn.com/tps/i1/T1N0pxFEhaXXXxK1nM-357-88.jpg' );
    imagecopymerge ( $target, $child1, 0, 400, 0, 0, imagesx ( $child1 ), imagesy ( $child1 ), 100 );
    //eof of 合成图片
 
    @mkdir ( './' . $date );
    imagejpeg ( $target, './' . $img, 95 );
 
    imagedestroy ( $main );
    imagedestroy ( $target );
    imagedestroy ( $child1 );
    return $img;
}
//http://my.oschina.net/cart/
generateImg ( 'http://1.popular.sinaapp.com/munv/pic.jpg', 'my.oschina.net/cart', 'PHP文字水平居中', '3个字' );
exit ();