无需言 做自己 业 ,精于勤 荒于嬉.
- GD 和图像处理 函数 imagegd 将 GD 图像输出到浏览器或文件
-
发表日期:2021-07-01 08:56:00 | 来源: | 分类:GD 和图像处理 函数
-
imagegd
(PHP 4 >= 4.0.7, PHP 5, PHP 7, PHP 8)
imagegd — 将 GD 图像输出到浏览器或文件
说明
imagegd(resource$image, string$filename= ?): boolimagegd() 将一个 GD 图像输出到
filename。image参数是由 imagecreatetruecolor() 函数返回的。filename参数为可选项,如果为空,则原始图像流会被直接输出。注意:
GD 格式一般是用来加载图像中的一部分时更快。注意 GD 格式只能用于兼容于 GD 的应用程序。
参见 imagegd2()。
- GD 和图像处理 函数 imagegif 输出图象到浏览器或文件。
-
发表日期:2021-07-01 08:56:00 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // 创建新的图像实例$im = imagecreatetruecolor(100, 100); // 设置背景为白色imagefilledrectangle($im, 0, 0, 99, 99, 0xFFFFFF); //在图像上写字imagestring($im, 3, 40, 20, 'GD Library', 0xFFBA00); // 输出图像到浏览器header('Content-Type: image/gif'); imagegif($im); imagedestroy($im); ?>示例2
<?php // 载入 PNG$png = imagecreatefrompng('./php.png'); // 以 GIF 保存图像imagegif($png, './php.gif'); // 释放内存imagedestroy($png); // 完工echo 'Converted PNG image to GIF with success!'; ?>示例3
<?php // 创建新的图像实例$im = imagecreatetruecolor(100, 100); // 在这里对图像进行一些操作// 处理输出if(function_exists('imagegif')){ // 针对 GIF header('Content-Type: image/gif'); imagegif($im); } elseif(function_exists('imagejpeg')){ // 针对 JPEG header('Content-Type: image/jpeg'); imagejpeg($im, NULL, 100); } elseif(function_exists('imagepng')){ // 针对 PNG header('Content-Type: image/png'); imagepng($im); } elseif(function_exists('imagewbmp')){ // 针对 WBMP header('Content-Type: image/vnd.wap.wbmp'); imagewbmp($im); } else{ imagedestroy($im); die('No image support in this PHP server'); } // 如果发现图像是以上的格式之一,就从内存中释放if($im){ imagedestroy($im); } ?>示例4
<?php if(imagetypes() & IMG_GIF){ header('Content-Type: image/gif'); imagegif($im); } elseif(imagetypes() & IMG_JPG){ /* ... etc. */ } ?>
- GD 和图像处理 函数 imagedashedline 画一虚线
-
发表日期:2021-07-01 08:56:00 | 来源: | 分类:GD 和图像处理 函数
-
imagedashedline
(PHP 4, PHP 5, PHP 7, PHP 8)
imagedashedline — 画一虚线
说明
imagedashedline(
resource$image,
int$x1,
int$y1,
int$x2,
int$y2,
int$color
): bool反对使用本函数。应该用 imagesetstyle() 和 imageline() 的组合替代之。
- GD 和图像处理 函数 imagegetclip Get the clipping rectangle
-
发表日期:2021-07-01 08:56:00 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php $im = imagecreate(100, 100); imagesetclip($im, 10,10, 89,89); print_r(imagegetclip($im));
- GD 和图像处理 函数 imagegetinterpolation Get the interpolation method
-
发表日期:2021-07-01 08:56:00 | 来源: | 分类:GD 和图像处理 函数
-
imagegetinterpolation
(PHP 8)
imagegetinterpolation — Get the interpolation method
说明
imagegetinterpolation(GdImage$image): intGets the currently set interpolation method of the
image.参数
-
image -
由图象创建函数(例如imagecreatetruecolor())返回的图象资源。
返回值
Returns the interpolation method.
更新日志
版本 说明 8.0.0 imageexpects a GdImage instance now; previously, a resource was expected.参见
- imagesetinterpolation() - Set the interpolation method
-
- GD 和图像处理 函数 imageistruecolor 检查图像是否为真彩色图像
-
发表日期:2021-07-01 08:56:00 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // $im is an image instance// Check if image is a true color image or notif(!imageistruecolor($im)){ // Create a new true color image instance $tc = imagecreatetruecolor(imagesx($im), imagesy($im)); imagecopy($tc, $im, 0, 0, 0, 0, imagesx($im), imagesy($im)); imagedestroy($im); $im = $tc; $tc = NULL; } // Continue working with image instance?>
- GD 和图像处理 函数 imagegrabscreen Captures the whole screen
-
发表日期:2021-07-01 08:56:00 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php $im = imagegrabscreen(); imagepng($im, "myscreenshot.png"); imagedestroy($im); ?>
- GD 和图像处理 函数 imagelayereffect 设定 alpha 混色标志以使用绑定的 libgd 分层效果
-
发表日期:2021-07-01 08:56:00 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // Setup an image$im = imagecreatetruecolor(100, 100); // Set a backgroundimagefilledrectangle($im, 0, 0, 100, 100, imagecolorallocate($im, 220, 220, 220)); // Apply the overlay alpha blending flagimagelayereffect($im, IMG_EFFECT_OVERLAY); // Draw two grey ellipsesimagefilledellipse($im, 50, 50, 40, 40, imagecolorallocate($im, 100, 255, 100)); imagefilledellipse($im, 50, 50, 50, 80, imagecolorallocate($im, 100, 100, 255)); imagefilledellipse($im, 50, 50, 80, 50, imagecolorallocate($im, 255, 100, 100)); // Outputheader('Content-type: image/png'); imagepng($im); imagedestroy($im); ?>
- GD 和图像处理 函数 imagegrabwindow Captures a window
-
发表日期:2021-07-01 08:56:00 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php $browser = new COM("InternetExplorer.Application"); $handle = $browser->HWND; $browser->Visible = true; $im = imagegrabwindow($handle); $browser->Quit(); imagepng($im, "iesnap.png"); imagedestroy($im); ?>示例2
<?php $browser = new COM("InternetExplorer.Application"); $handle = $browser->HWND; $browser->Visible = true; $browser->Navigate("http://www.libgd.org"); /* Still working? */ while ($browser->Busy) { com_message_pump(4000); } $im = imagegrabwindow($handle, 0); $browser->Quit(); imagepng($im, "iesnap.png"); imagedestroy($im); ?>
- GD 和图像处理 函数 imageinterlace 启用或禁用隔行扫描
-
发表日期:2021-07-01 08:56:00 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // 创建一个图像实例$im = imagecreatefromgif('php.gif'); // 打开隔行扫描imageinterlace($im, true); // 保存图像imagegif($im, './php_interlaced.gif'); imagedestroy($im); ?>
- GD 和图像处理 函数 imageloadfont 载入一新字体
-
发表日期:2021-07-01 08:56:00 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php header("Content-type: image/png"); $im = imagecreatetruecolor(50, 20); $black = imagecolorallocate($im, 0, 0, 0); $white = imagecolorallocate($im, 255, 255, 255); imagefilledrectangle($im, 0, 0, 49, 19, $white); $font = imageloadfont("04b.gdf"); imagestring($im, $font, 0, 0, "Hello", $black); imagepng($im); ?>
- GD 和图像处理 函数 imageopenpolygon Draws an open polygon
-
发表日期:2021-07-01 08:56:00 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // Create a blank image$image = imagecreatetruecolor(400, 300); // Allocate a color for the polygon$col_poly = imagecolorallocate($image, 255, 255, 255); // Draw the polygonimageopenpolygon($image, array( 0, 0, 100, 200, 300, 200 ), 3, $col_poly); // Output the picture to the browserheader('Content-type: image/png'); imagepng($image); imagedestroy($image); ?>
- GD 和图像处理 函数 imageline 画一条线段
-
发表日期:2021-07-01 08:56:00 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php function imagelinethick($image, $x1, $y1, $x2, $y2, $color, $thick = 1){ /* 下面两行只在线段直角相交时好使 imagesetthickness($image, $thick); return imageline($image, $x1, $y1, $x2, $y2, $color); */ if ($thick == 1) { return imageline($image, $x1, $y1, $x2, $y2, $color); } $t = $thick / 2 - 0.5; if ($x1 == $x2 || $y1 == $y2) { return imagefilledrectangle($image, round(min($x1, $x2) - $t), round(min($y1, $y2) - $t), round(max($x1, $x2) + $t), round(max($y1, $y2) + $t), $color); } $k = ($y2 - $y1) / ($x2 - $x1); //y = kx + q $a = $t / sqrt(1 + pow($k, 2)); $points = array( round($x1 - (1+$k)*$a), round($y1 + (1-$k)*$a), round($x1 - (1-$k)*$a), round($y1 - (1+$k)*$a), round($x2 + (1+$k)*$a), round($y2 - (1-$k)*$a), round($x2 + (1-$k)*$a), round($y2 + (1+$k)*$a), ); imagefilledpolygon($image, $points, 4, $color); return imagepolygon($image, $points, 4, $color); } ?>
- GD 和图像处理 函数 imagejpeg 输出图象到浏览器或文件。
-
发表日期:2021-07-01 08:56:00 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // 创键空白图像并添加一些文本$im = imagecreatetruecolor(120, 20); $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color); // 设置内容类型标头 —— 这个例子里是 image/jpegheader('Content-Type: image/jpeg'); // 输出图像imagejpeg($im); // 释放内存imagedestroy($im); ?>示例2
<?php // 创键空白图像并添加一些文本$im = imagecreatetruecolor(120, 20); $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color); // 保存图像为 'simpletext.jpg'imagejpeg($im, 'simpletext.jpg'); // 释放内存imagedestroy($im); ?>
示例3
<?php // 创键空白图像并添加一些文本$im = imagecreatetruecolor(120, 20); $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color); // 设置内容类型标头 —— 这个例子里是 image/jpegheader('Content-Type: image/jpeg'); // 使用 NULL 跳过 filename 参数,并设置图像质量为 75%imagejpeg($im, NULL, 75); // 释放内存imagedestroy($im); ?>
- GD 和图像处理 函数 imagepalettecopy 将调色板从一幅图像拷贝到另一幅
-
发表日期:2021-07-01 08:56:00 | 来源: | 分类:GD 和图像处理 函数
-
imagepalettecopy
(PHP 4 >= 4.0.1, PHP 5, PHP 7, PHP 8)
imagepalettecopy — 将调色板从一幅图像拷贝到另一幅
说明
imagepalettecopy(resource$destination, resource$source): voidimagepalettecopy() 从
source图像把调色板拷贝到destination图像。
- GD 和图像处理 函数 imagecreatefromxpm 由文件或 URL 创建一个新图象。
-
发表日期:2021-07-01 08:55:59 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // Check for XPM supportif(!(imagetypes() & IMG_XPM)){ die('Support for xpm was not found!'); } // Create the image instance$xpm = imagecreatefromxpm('./example.xpm'); // Do image operations here// PHP has no support for writing xpm images// so in this case we save the image as a // jpeg file with 100% qualityimagejpeg($xpm, './example.jpg', 100); imagedestroy($xpm); ?>
- GD 和图像处理 函数 imagecreatetruecolor 新建一个真彩色图像
-
发表日期:2021-07-01 08:55:59 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php header ('Content-Type: image/png'); $im = @imagecreatetruecolor(120, 20) or die('Cannot Initialize new GD image stream'); $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color); imagepng($im); imagedestroy($im); ?>
- GD 和图像处理 函数 imagedestroy 销毁一图像
-
发表日期:2021-07-01 08:55:59 | 来源: | 分类:GD 和图像处理 函数
-
imagedestroy
(PHP 4, PHP 5, PHP 7, PHP 8)
imagedestroy — 销毁一图像
说明
imagedestroy(resource$image): boolimagedestroy() 释放与
image关联的内存。image是由图像创建函数返回的图像标识符,例如 imagecreatetruecolor()。
- GD 和图像处理 函数 imagefill 区域填充
-
发表日期:2021-07-01 08:55:59 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php $im = imagecreatetruecolor(100, 100); // 将背景设为红色$red = imagecolorallocate($im, 255, 0, 0); imagefill($im, 0, 0, $red); header('Content-type: image/png'); imagepng($im); imagedestroy($im); ?>
- GD 和图像处理 函数 imagefilledarc 画一椭圆弧且填充
-
发表日期:2021-07-01 08:55:59 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // 创建图像$image = imagecreatetruecolor(100, 100); // 分配一些颜色$white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); $gray = imagecolorallocate($image, 0xC0, 0xC0, 0xC0); $darkgray = imagecolorallocate($image, 0x90, 0x90, 0x90); $navy = imagecolorallocate($image, 0x00, 0x00, 0x80); $darknavy = imagecolorallocate($image, 0x00, 0x00, 0x50); $red = imagecolorallocate($image, 0xFF, 0x00, 0x00); $darkred = imagecolorallocate($image, 0x90, 0x00, 0x00); // 创建 3D 效果for ($i = 60; $i > 50; $i--) { imagefilledarc($image, 50, $i, 100, 50, 0, 45, $darknavy, IMG_ARC_PIE); imagefilledarc($image, 50, $i, 100, 50, 45, 75 , $darkgray, IMG_ARC_PIE); imagefilledarc($image, 50, $i, 100, 50, 75, 360 , $darkred, IMG_ARC_PIE); } imagefilledarc($image, 50, 50, 100, 50, 0, 45, $navy, IMG_ARC_PIE); imagefilledarc($image, 50, 50, 100, 50, 45, 75 , $gray, IMG_ARC_PIE); imagefilledarc($image, 50, 50, 100, 50, 75, 360 , $red, IMG_ARC_PIE); // 输出图像header('Content-type: image/png'); imagepng($image); imagedestroy($image); ?>
- 前端开发(1)
- 数据库(0)
- PHP(0)
- PHP杂项(34)
- PHP基础-李炎恢系列课程(20)
- 中文函数手册(0)
- 错误处理 函数(13)
- OPcache 函数(6)
- PHP 选项/信息 函数(54)
- Zip 函数(10)
- Hash 函数(15)
- OpenSSL 函数(63)
- Date/Time 函数(51)
- 目录函数(9)
- Fileinfo 函数(6)
- iconv 函数(11)
- 文件系统函数(81)
- 多字节字符串 函数(57)
- GD 和图像处理 函数(114)
- 可交换图像信息(5)
- Math 函数(50)
- 程序执行函数(11)
- PCNTL 函数(23)
- JSON 函数(4)
- SPL 函数(15)
- URL 函数(10)
- cURL 函数(32)
- 网络 函数(33)
- FTP 函数(36)
- Session 函数(23)
- PCRE 函数(11)
- PCRE 正则语法(19)
- 数组 函数(81)
- 类/对象 函数(18)
- 函数处理 函数(13)
- 变量处理 函数(37)
- SimpleXML 函数(3)
- 杂项 函数(31)
- 字符串 函数(101)
- JAVA(0)
- Android(0)
- Linux(0)
- AI大模型(9)
- 其他(0)
宁公网安备 64010402001209号