PHP drawing technology examples explained

小云云
Release: 2023-03-20 16:28:01
Original
3226 people have browsed it

Learn vector pictures (verification codes), draw and generate reports. Hope this article can help everyone.

Steps

创建画布 会只需要的各种图形(圆,直线,矩形,弧线,扇形) 输出图像到网页,也可以另存 销毁图片(释放内存)
Copy after login

Picture format

gif 图片压缩率高, 但是只能显示256色可能造成颜色丢失,但可以显示动画 jpg/jpeg 图片的压缩率高,可以用较小的文件来显示 网页上用的比较多 png,高仿真 综合了gif和jpg的优势,但是不能显示动画
Copy after login

Quick Start

创建画布$img = imagecreatetruecolor(100,100); 取色$red = imagecolorallocate($img, 255, 0, 0); 画图 •imagefilledarc — 画一椭圆弧且填充 •imagefilledellipse — 画一椭圆并填充 •imagefilledpolygon — 画一多边形并填充 •imagefilledrectangle — 画一矩形并填充 输出到浏览器header("content-type: image/png"); imagepng($img); 销毁 imagedestroy($img);
Copy after login

Picture to canvas

$srcImage = imagecreatefromgif(filename);$srcImage_info = getimagesize(filename); imagecopy(dst_im, src_im, dst_x, dst_y, src_x, src_y, src_w, src_h); 具体参数含义 不懂看文档
Copy after login

Writing

imagettftext(image, size, angle, x, y, color, fontfile, text)
Copy after login

Generate verification code

Copy after login

Related recommendations:

Examples of php drawing technology

Key points and applications of drawing technology in php Summary

Common functions of php drawing technology

The above is the detailed content of PHP drawing technology examples explained. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!