将图形以JPEG格式输出到浏览器或文件
JPEG格式是一种被广泛使用的失真压缩标准方法,其主要扩展有:.jpg、.JPG、.jpeg、.jfif、JPE。使用imagejpeg()函数,可以把图形以JPEG格式,输出到浏览器或文件中。下面介绍imagejpeg()函数的使用方法,代码如清单所示。
<?php
//创建一个新图形
$image = imagecreatetruecolor(400,100);
//分配颜色
$bgColor = imagecolorallocate($image,250,250,250);
$black = imagecolorallocate($image,0,0,0);
//填充背景
imagefill($image,0,0,$bgColor);
//指定imagettftext()函数使用的字体
$f......
阅读全文