无需言 做自己 业 ,精于勤 荒于嬉.
- GD 和图像处理 函数 imagefilledpolygon 画一多边形并填充
-
发表日期:2021-07-01 08:55:59 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // 建立多边形各顶点坐标的数组$values = array( 40, 50, // Point 1 (x, y) 20, 240, // Point 2 (x, y) 60, 60, // Point 3 (x, y) 240, 20, // Point 4 (x, y) 50, 40, // Point 5 (x, y) 10, 10 // Point 6 (x, y) ); // 创建图像$image = imagecreatetruecolor(250, 250); // 设定颜色$bg = imagecolorallocate($image, 200, 200, 200); $blue = imagecolorallocate($image, 0, 0, 255); // 画一个多边形imagefilledpolygon($image, $values, 6, $blue); // 输出图像header('Content-type: image/png'); imagepng($image); imagedestroy($image); ?>
- GD 和图像处理 函数 imagefilledellipse 画一椭圆并填充
-
发表日期:2021-07-01 08:55:59 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // create a blank image$image = imagecreatetruecolor(400, 300); // fill the background color$bg = imagecolorallocate($image, 0, 0, 0); // choose a color for the ellipse$col_ellipse = imagecolorallocate($image, 255, 255, 255); // draw the white ellipseimagefilledellipse($image, 200, 150, 300, 200, $col_ellipse); // output the pictureheader("Content-type: image/png"); imagepng($image); ?>
- GD 和图像处理 函数 imageellipse 画一个椭圆
-
发表日期:2021-07-01 08:55:59 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // 新建一个空白图像$image = imagecreatetruecolor(400, 300); // 填充背景色$bg = imagecolorallocate($image, 0, 0, 0); // 选择椭圆的颜色$col_ellipse = imagecolorallocate($image, 255, 255, 255); // 画一个椭圆imageellipse($image, 200, 150, 300, 200, $col_ellipse); // 输出图像header("Content-type: image/png"); imagepng($image); ?>
- GD 和图像处理 函数 imagefilledrectangle 画一矩形并填充
-
发表日期:2021-07-01 08:55:59 | 来源: | 分类:GD 和图像处理 函数
-
imagefilledrectangle
(PHP 4, PHP 5, PHP 7, PHP 8)
imagefilledrectangle — 画一矩形并填充
说明
imagefilledrectangle(
resource$image,
int$x1,
int$y1,
int$x2,
int$y2,
int$color
): boolimagefilledrectangle() 在
image图像中画一个用color颜色填充了的矩形,其左上角坐标为x1,y1,右下角坐标为x2,y2。0, 0 是图像的最左上角。
- GD 和图像处理 函数 imageflip Flips an image using a given mode
-
发表日期:2021-07-01 08:55:59 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // File$filename = 'phplogo.png'; // Content typeheader('Content-type: image/png'); // Load$im = imagecreatefrompng($filename); // Flip it verticallyimageflip($im, IMG_FLIP_VERTICAL); // Outputimagejpeg($im); imagedestroy($im); ?>示例2
<?php // File$filename = 'phplogo.png'; // Content typeheader('Content-type: image/png'); // Load$im = imagecreatefrompng($filename); // Flip it horizontallyimageflip($im, IMG_FLIP_HORIZONTAL); // Outputimagejpeg($im); imagedestroy($im); ?>
- GD 和图像处理 函数 imagefontheight 取得字体高度
-
发表日期:2021-07-01 08:55:59 | 来源: | 分类:GD 和图像处理 函数
-
imagefontheight
(PHP 4, PHP 5, PHP 7, PHP 8)
imagefontheight — 取得字体高度
- GD 和图像处理 函数 imagefilltoborder 区域填充到指定颜色的边界为止
-
发表日期:2021-07-01 08:55:59 | 来源: | 分类:GD 和图像处理 函数
-
imagefilltoborder
(PHP 4, PHP 5, PHP 7, PHP 8)
imagefilltoborder — 区域填充到指定颜色的边界为止
说明
imagefilltoborder(
resource$image,
int$x,
int$y,
int$border,
int$color
): boolimagefilltoborder() 从
x,y(图像左上角为 0, 0)点开始用color颜色执行区域填充,直到碰到颜色为border的边界为止。【注:边界内的所有颜色都会被填充。如果指定的边界色和该点颜色相同,则没有填充。如果图像中没有该边界色,则整幅图像都会被填充。】
- GD 和图像处理 函数 imagefilter 对图像使用过滤器
-
发表日期:2021-07-01 08:55:59 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php $im = imagecreatefrompng('dave.png'); if ($im && imagefilter($im, IMG_FILTER_GRAYSCALE)) { echo 'Image converted to grayscale.'; imagepng($im, 'dave.png'); } else { echo 'Conversion to grayscale failed.'; } imagedestroy($im); ?>示例2
<?php $im = imagecreatefrompng('sean.png'); if ($im && imagefilter($im, IMG_FILTER_BRIGHTNESS, 20)) { echo 'Image brightness changed.'; imagepng($im, 'sean.png'); } else { echo 'Image brightness change failed.'; } imagedestroy($im); ?>示例3
<?php $im = imagecreatefrompng('philip.png'); /* R, G, B, so 0, 255, 0 is green */ if ($im && imagefilter($im, IMG_FILTER_COLORIZE, 0, 255, 0)) { echo 'Image successfully shaded green.'; imagepng($im, 'philip.png'); } else { echo 'Green shading failed.'; } imagedestroy($im); ?>示例4
<?php $im = imagecreatefrompng('dave.png'); if($im && imagefilter($im, IMG_FILTER_GRAYSCALE)){ echo 'Image converted to grayscale.'; imagepng($im, 'dave.png'); } else{ echo 'Conversion to grayscale failed.'; } imagedestroy($im); ?>示例5
<?php $im = imagecreatefrompng('sean.png'); if($im && imagefilter($im, IMG_FILTER_BRIGHTNESS, 20)){ echo 'Image brightness changed.'; imagepng($im, 'sean.png'); imagedestroy($im); } else{ echo 'Image brightness change failed.'; } ?>示例6
<?php $im = imagecreatefrompng('philip.png'); /* R, G, B, so 0, 255, 0 is green */ if($im && imagefilter($im, IMG_FILTER_COLORIZE, 0, 255, 0)){ echo 'Image successfully shaded green.'; imagepng($im, 'philip.png'); imagedestroy($im); } else{ echo 'Green shading failed.'; } ?>示例7
<?php // Define our negate function so its portable for // php versions without imagefilter()function negate($im){ if(function_exists('imagefilter')) { return imagefilter($im, IMG_FILTER_NEGATE); } for($x = 0; $x < imagesx($im); ++$x) { for($y = 0; $y < imagesy($im); ++$y) { $index = imagecolorat($im, $x, $y); $rgb = imagecolorsforindex($index); $color = imagecolorallocate($im, 255 - $rgb['red'], 255 - $rgb['green'], 255 - $rgb['blue']); imagesetpixel($im, $x, $y, $color); } } return(true); } $im = imagecreatefromjpeg('kalle.jpg'); if($im && negate($im)){ echo 'Image successfully converted to negative colors.'; imagejpeg($im, 'kalle.jpg', 100); imagedestroy($im); } else{ echo 'Converting to negative colors failed.'; } ?>示例8
<?php // Load the PHP logo, we need to create two instances // to show the differences$logo1 = imagecreatefrompng('./php.png'); $logo2 = imagecreatefrompng('./php.png'); // Create the image instance we want to show the // differences on$output = imagecreatetruecolor(imagesx($logo1) * 2, imagesy($logo1)); // Apply pixelation to each instance, with a block // size of 3imagefilter($logo1, IMG_FILTER_PIXELATE, 3); imagefilter($logo2, IMG_FILTER_PIXELATE, 3, true); // Merge the differences onto the output imageimagecopy($output, $logo1, 0, 0, 0, 0, imagesx($logo1) - 1, imagesy($logo1) - 1); imagecopy($output, $logo2, imagesx($logo2), 0, 0, 0, imagesx($logo2) - 1, imagesy($logo2) - 1); imagedestroy($logo1); imagedestroy($logo2); // Output the differencesheader('Content-Type: image/png'); imagepng($output); imagedestroy($output); ?>
- GD 和图像处理 函数 imagefontwidth 取得字体宽度
-
发表日期:2021-07-01 08:55:59 | 来源: | 分类:GD 和图像处理 函数
-
imagefontwidth
(PHP 4, PHP 5, PHP 7, PHP 8)
imagefontwidth — 取得字体宽度
- GD 和图像处理 函数 imageftbbox 给出一个使用 FreeType 2 字体的文本框
-
发表日期:2021-07-01 08:55:59 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // Create a 300x150 image$im = imagecreatetruecolor(300, 150); $black = imagecolorallocate($im, 0, 0, 0); $white = imagecolorallocate($im, 255, 255, 255); // Set the background to be whiteimagefilledrectangle($im, 0, 0, 299, 299, $white); // Path to our font file$font = './arial.ttf'; // First we create our bounding box$bbox = imageftbbox(10, 0, $font, 'The PHP Documentation Group'); // This is our cordinates for X and Y$x = $bbox[0] + (imagesx($im) / 2) - ($bbox[4] / 2) - 5; $y = $bbox[1] + (imagesy($im) / 2) - ($bbox[5] / 2) - 5; imagefttext($im, 10, 0, $x, $y, $black, $font, 'The PHP Documentation Group'); // Output to browserheader('Content-Type: image/png'); imagepng($im); imagedestroy($im); ?>
- GD 和图像处理 函数 imagegammacorrect 对 GD 图像应用 gamma 修正
-
发表日期:2021-07-01 08:55:59 | 来源: | 分类:GD 和图像处理 函数
-
imagegammacorrect
(PHP 4, PHP 5, PHP 7, PHP 8)
imagegammacorrect — 对 GD 图像应用 gamma 修正
说明
imagegammacorrect(resource$image, float$inputgamma, float$outputgamma): boolimagegammacorrect() 函数用给定的输入 gamma 值
inputgamma和输出 gamma 值outputgamma对一幅 GD 图像流(image)应用 gamma 修正。
- GD 和图像处理 函数 imagegd2 将 GD2 图像输出到浏览器或文件
-
发表日期:2021-07-01 08:55:59 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // Create a blank image and add some text$im = imagecreatetruecolor(120, 20); $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 1, 5, 5, "A Simple Text String", $text_color); // Output the imageimagegd2($im); // Free up memoryimagedestroy($im); ?>
示例2
<?php // Create a blank image and add some text$im = imagecreatetruecolor(120, 20); $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 1, 5, 5, "A Simple Text String", $text_color); // Save the gd2 image// The file format for GD2 images is .gd2, see http://www.libgd.org/GdFileFormatsimagegd2($im, 'simple.gd2'); // Free up memoryimagedestroy($im); ?>
- GD 和图像处理 函数 imagecreatefrombmp 由文件或 URL 创建一个新图象。
-
发表日期:2021-07-01 08:55:58 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // Load the BMP file$im = imagecreatefrombmp('./example.bmp'); // Convert it to a PNG file with default settingsimagepng($im, './example.png'); imagedestroy($im); ?>
- GD 和图像处理 函数 imagecopyresized 拷贝部分图像并调整大小
-
发表日期:2021-07-01 08:55:58 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // File and new size$filename = 'test.jpg'; $percent = 0.5; // Content typeheader('Content-Type: image/jpeg'); // Get new sizeslist($width, $height) = getimagesize($filename); $newwidth = $width * $percent; $newheight = $height * $percent; // Load$thumb = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefromjpeg($filename); // Resizeimagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); // Outputimagejpeg($thumb); ?>
- GD 和图像处理 函数 imagecreate 新建一个基于调色板的图像
-
发表日期:2021-07-01 08:55:58 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php header("Content-type: image/png"); $im = @imagecreate(100, 50) or die("Cannot Initialize new GD image stream"); $background_color = imagecolorallocate($im, 255, 255, 255); $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 1, 5, 5, "A Simple Text String", $text_color); imagepng($im); imagedestroy($im); ?>
- GD 和图像处理 函数 imagecreatefromgd2 从 GD2 文件或 URL 新建一图像
-
发表日期:2021-07-01 08:55:58 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // 加载 gd2 图像$im = imagecreatefromgd2('./test.gd2'); // 在图像上应用效果。// 在这个例子中,如果版本为 PHP5+ 则反转图像颜色if(function_exists('imagefilter')){ imagefilter($im, IMG_FILTER_NEGATE); } // 保存图像imagegd2($im, './test_updated.gd2'); imagedestroy($im); ?>
- GD 和图像处理 函数 imagecreatefromgd2part 从给定的 GD2 文件或 URL 中的部分新建一图像
-
发表日期:2021-07-01 08:55:58 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // For this example we need the image size before$image = getimagesize('./test.gd2'); // Create the image instance now we got the image // sizes$im = imagecreatefromgd2part('./test.gd2', 4, 4, ($image[0] / 2) - 6, ($image[1] / 2) - 6); // Do an image operation, in this case we emboss the // image if PHP 5+if(function_exists('imagefilter')){ imagefilter($im, IMG_FILTER_EMBOSS); } // Save optimized imageimagegd2($im, './test_emboss.gd2'); imagedestroy($im); ?>
- GD 和图像处理 函数 imagecreatefromgd 从 GD 文件或 URL 新建一图像
-
发表日期:2021-07-01 08:55:58 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php // Load the gd image$im = @imagecreatefromgd('./test.gd'); // Test if the image was loadedif(!is_resource($im)){ die('Unable to load gd image!'); } // Do image operations here// Save the imageimagegd($im, './test_updated.gd'); imagedestroy($im); ?>
- GD 和图像处理 函数 imagecreatefromgif 由文件或 URL 创建一个新图象。
-
发表日期:2021-07-01 08:55:58 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php function LoadGif($imgname){ /* Attempt to open */ $im = @imagecreatefromgif($imgname); /* See if it failed */ if(!$im) { /* Create a blank image */ $im = imagecreatetruecolor (150, 30); $bgc = imagecolorallocate ($im, 255, 255, 255); $tc = imagecolorallocate ($im, 0, 0, 0); imagefilledrectangle ($im, 0, 0, 150, 30, $bgc); /* Output an error message */ imagestring ($im, 1, 5, 5, 'Error loading ' . $imgname, $tc); } return $im; } header('Content-Type: image/gif'); $img = LoadGif('bogus.image'); imagegif($img); imagedestroy($img); ?>
- GD 和图像处理 函数 imagecreatefromjpeg 由文件或 URL 创建一个新图象。
-
发表日期:2021-07-01 08:55:58 | 来源: | 分类:GD 和图像处理 函数
-
示例1
<?php function LoadJpeg($imgname){ /* 尝试打开 */ $im = @imagecreatefromjpeg($imgname); /* See if it failed */ if(!$im) { /* Create a black image */ $im = imagecreatetruecolor(150, 30); $bgc = imagecolorallocate($im, 255, 255, 255); $tc = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 150, 30, $bgc); /* Output an error message */ imagestring($im, 1, 5, 5, 'Error loading ' . $imgname, $tc); } return $im; } header('Content-Type: image/jpeg'); $img = LoadJpeg('bogus.image'); imagejpeg($img); imagedestroy($img); ?>
- 前端开发(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号