无需言 做自己 业 ,精于勤 荒于嬉.

GD 和图像处理 函数 imagecolorclosesthwb 取得与给定颜色最接近的色度的黑白色的索引

发表日期:2021-07-01 08:55:57 | 来源: | 分类:GD 和图像处理 函数

      示例1
<?php 
$im = imagecreatefromgif('php.gif');
echo 'HWB: ' . imagecolorclosesthwb($im, 116, 115, 152);
imagedestroy($im);
?>

阅读全文 »

GD 和图像处理 函数 imagecolorat 取得某像素的颜色索引值

发表日期:2021-07-01 08:55:57 | 来源: | 分类:GD 和图像处理 函数

      示例1
<?php 
$im = ImageCreateFromPng("rockym.png");
$rgb = ImageColorAt($im, 100, 100);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
?>

阅读全文 »

GD 和图像处理 函数 imagecolormatch 使一个图像中调色板版本的颜色与真彩色版本更能匹配

发表日期:2021-07-01 08:55:57 | 来源: | 分类:GD 和图像处理 函数

      示例1
<?php 
// Setup the true color and palette images$im1 = imagecreatefrompng('./gdlogo.png');
$im2 = imagecreate(imagesx($im1), imagesy($im1));
// Add some colors to $im2$colors   = Array();
$colors[] = imagecolorallocate($im2, 255, 36, 74);
$colors[] = imagecolorallocate($im2, 40, 0, 240);
$colors[] = imagecolorallocate($im2, 82, 100, 255);
$colors[] = imagecolorallocate($im2, 84, 63, 44);
// Match these colors with the true color imageimagecolormatch($im1, $im2);
// Free from memoryimagedestroy($im1);
imagedestroy($im2);
?>

阅读全文 »

GD 和图像处理 函数 imagecolordeallocate 取消图像颜色的分配

发表日期:2021-07-01 08:55:57 | 来源: | 分类:GD 和图像处理 函数

      示例1
<?php 
$white = imagecolorallocate($im, 255, 255, 255);
imagecolordeallocate($im, $white);
?>

阅读全文 »

GD 和图像处理 函数 imagecolorexactalpha 取得指定的颜色加透明度的索引值

发表日期:2021-07-01 08:55:57 | 来源: | 分类:GD 和图像处理 函数

      示例1
<?php 
// Setup an image$im = imagecreatefrompng('./gdlogo.png');
$colors   = Array();
$colors[] = imagecolorexactalpha($im, 255, 0, 0, 0);
$colors[] = imagecolorexactalpha($im, 0, 0, 0, 127);
$colors[] = imagecolorexactalpha($im, 255, 255, 255, 55);
$colors[] = imagecolorexactalpha($im, 100, 255, 52, 20);
print_r($colors);
// Free from memoryimagedestroy($im);
?>

阅读全文 »

GD 和图像处理 函数 imagecolorset 给指定调色板索引设定颜色

发表日期:2021-07-01 08:55:57 | 来源: | 分类:GD 和图像处理 函数

imagecolorset

(PHP 4, PHP 5, PHP 7, PHP 8)

imagecolorset给指定调色板索引设定颜色

说明

imagecolorset(
    resource $image,
    int $index,
    int $red,
    int $green,
    int $blue
): void

本函数将调色板中指定的索引设定为指定的颜色。对于在调色板图像中创建类似区域填充(flood-fill)的效果很有用,免去了真的去填充的开销。

参见 imagecolorat()

阅读全文 »

GD 和图像处理 函数 imagecolorsforindex 取得某索引的颜色

发表日期:2021-07-01 08:55:57 | 来源: | 分类:GD 和图像处理 函数

      示例1
<?php 
// 打开一幅图像$im = imagecreatefrompng('nexen.png');
// 取得一点的颜色$start_x = 40;
$start_y = 50;
$color_index = imagecolorat($im, $start_x, $start_y);
// 使其可读$color_tran = imagecolorsforindex($im, $color_index);
// 显示该颜色的值echo '<pre>';
print_r($color_tran);
echo '</pre>';
?>

阅读全文 »

GD 和图像处理 函数 imagecolorresolve 取得指定颜色的索引值或有可能得到的最接近的替代值

发表日期:2021-07-01 08:55:57 | 来源: | 分类:GD 和图像处理 函数

imagecolorresolve

(PHP 4, PHP 5, PHP 7, PHP 8)

imagecolorresolve取得指定颜色的索引值或有可能得到的最接近的替代值

说明

imagecolorresolve(
    resource $image,
    int $red,
    int $green,
    int $blue
): int

本函数可以保证对所请求的颜色返回一个颜色索引,要么是确切值要么是所能得到最接近的替代值。

如果从文件创建了图像,只有图像中使用了的颜色会被辨析。仅出现在调色板中的颜色不会被辨析。

参见 imagecolorclosest()

阅读全文 »

GD 和图像处理 函数 imagecolorstotal 取得一幅图像的调色板中颜色的数目

发表日期:2021-07-01 08:55:57 | 来源: | 分类:GD 和图像处理 函数

imagecolorstotal

(PHP 4, PHP 5, PHP 7, PHP 8)

imagecolorstotal取得一幅图像的调色板中颜色的数目

说明

imagecolorstotal(resource $image): int

本函数返回指定图像的调色板中的颜色数目。

参见 imagecolorat()imagecolorsforindex()

阅读全文 »

GD 和图像处理 函数 imagecolortransparent 将某个颜色定义为透明色

发表日期:2021-07-01 08:55:57 | 来源: | 分类:GD 和图像处理 函数

imagecolortransparent

(PHP 4, PHP 5, PHP 7, PHP 8)

imagecolortransparent将某个颜色定义为透明色

说明

imagecolortransparent(resource $image, int $color = ?): int

imagecolortransparent()image 图像中的透明色设定为 colorimageimagecreatetruecolor() 返回的图像标识符,colorimagecolorallocate() 返回的颜色标识符。

注意:

透明色是图像的一种属性,透明度不是颜色的属性。一旦设定了某个颜色为透明色,图像中之前画为该色的任何区域都成为透明的。

返回新透明色的标识符,如果省略 color 则返回当前透明色的标识符。

注意:

透明度仅能通过 imagecopymerge() 和真彩色图像拷贝,不能用 imagecopy() 或调色板图像。

阅读全文 »

GD 和图像处理 函数 imagecopy 拷贝图像的一部分

发表日期:2021-07-01 08:55:57 | 来源: | 分类:GD 和图像处理 函数

imagecopy

(PHP 4, PHP 5, PHP 7, PHP 8)

imagecopy拷贝图像的一部分

说明

imagecopy(
    resource $dst_im,
    resource $src_im,
    int $dst_x,
    int $dst_y,
    int $src_x,
    int $src_y,
    int $src_w,
    int $src_h
): bool

src_im 图像中坐标从 src_xsrc_y 开始,宽度为 src_w,高度为 src_h 的一部分拷贝到 dst_im 图像中坐标为 dst_xdst_y 的位置上。

阅读全文 »

GD 和图像处理 函数 imagecopymerge 拷贝并合并图像的一部分

发表日期:2021-07-01 08:55:57 | 来源: | 分类:GD 和图像处理 函数

imagecopymerge

(PHP 4 >= 4.0.1, PHP 5, PHP 7, PHP 8)

imagecopymerge拷贝并合并图像的一部分

说明

imagecopymerge(
    resource $dst_im,
    resource $src_im,
    int $dst_x,
    int $dst_y,
    int $src_x,
    int $src_y,
    int $src_w,
    int $src_h,
    int $pct
): bool

src_im 图像中坐标从 src_xsrc_y 开始,宽度为 src_w,高度为 src_h 的一部分拷贝到 dst_im 图像中坐标为 dst_xdst_y 的位置上。两图像将根据 pct 来决定合并程度,其值范围从 0 到 100。当 pct = 0 时,实际上什么也没做,当为 100 时对于调色板图像本函数和 imagecopy() 完全一样,它对真彩色图像实现了 alpha 透明。

注意:

本函数是 PHP 4.0.6 新加的。

阅读全文 »

GD 和图像处理 函数 imagecopymergegray 用灰度拷贝并合并图像的一部分

发表日期:2021-07-01 08:55:57 | 来源: | 分类:GD 和图像处理 函数

imagecopymergegray

(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)

imagecopymergegray用灰度拷贝并合并图像的一部分

说明

imagecopymergegray(
    resource $dst_im,
    resource $src_im,
    int $dst_x,
    int $dst_y,
    int $src_x,
    int $src_y,
    int $src_w,
    int $src_h,
    int $pct
): bool

src_im 图像中坐标从 src_xsrc_y 开始,宽度为 src_w,高度为 src_h 的一部分拷贝到 dst_im 图像中坐标为 dst_xdst_y 的位置上。两图像将根据 pct 来决定合并程度,其值范围从 0 到 100。当 pct = 0 时,实际上什么也没做,当为 100 时本函数和 imagecopy() 完全一样。

本函数和 imagecopymerge() 完全一样只除了合并时通过在拷贝操作前将目标像素转换为灰度级来保留了原色度。

注意:

本函数添加于 PHP 4.0.6。

阅读全文 »

GD 和图像处理 函数 imageconvolution 用系数 div 和 offset 申请一个 3x3 的卷积矩阵

发表日期:2021-07-01 08:55:57 | 来源: | 分类:GD 和图像处理 函数

      示例1
<?php 
$image = imagecreatefromgif('http://www.php.net/images/php.gif');
$emboss = array(array(2, 0, 0), array(0, -1, 0), array(0, 0, -1));
imageconvolution($image, $emboss, 1, 127);
header('Content-Type: image/png');
imagepng($image, null, 9);
?>
      示例2
<?php 
$image = imagecreatetruecolor(180,40);
// Writes the text and apply a gaussian blur on the imageimagestring($image, 5, 10, 8, 'Gaussian Blur Text', 0x00ff00);
$gaussian = array(array(1.0, 2.0, 1.0), array(2.0, 4.0, 2.0), array(1.0, 2.0, 1.0));
imageconvolution($image, $gaussian, 16, 0);
// Rewrites the text for comparisonimagestring($image, 5, 10, 18, 'Gaussian Blur Text', 0x00ff00);
header('Content-Type: image/png');
imagepng($image, null, 9);
?>

阅读全文 »

GD 和图像处理 函数 imagecolorresolvealpha 取得指定颜色 + alpha 的索引值或有可能得到的最接近的替代值

发表日期:2021-07-01 08:55:57 | 来源: | 分类:GD 和图像处理 函数

      示例1
<?php 
// Load an image$im = imagecreatefromgif('phplogo.gif');
// Get closest colors from the image$colors = array();
$colors[] = imagecolorresolvealpha($im, 255, 255, 255, 0);
$colors[] = imagecolorresolvealpha($im, 0, 0, 200, 127);
// Outputprint_r($colors);
imagedestroy($im);
?>

阅读全文 »

GD 和图像处理 函数 imagecolorexact 取得指定颜色的索引值

发表日期:2021-07-01 08:55:57 | 来源: | 分类:GD 和图像处理 函数

imagecolorexact

(PHP 4, PHP 5, PHP 7, PHP 8)

imagecolorexact取得指定颜色的索引值

说明

imagecolorexact(
    resource $image,
    int $red,
    int $green,
    int $blue
): int

返回图像调色板中指定颜色的索引值。

如果颜色不在图像的调色板中,返回 -1。

如果从文件创建了图像,只有图像中使用了的颜色会被辨析。仅出现在调色板中的颜色不会被辨析。

参见 imagecolorclosest()

阅读全文 »

GD 和图像处理 函数 getimagesizefromstring 从字符串中获取图像尺寸信息

发表日期:2021-07-01 08:55:56 | 来源: | 分类:GD 和图像处理 函数

      示例1
<?php 
$img = '/path/to/test.png';
// 以文件方式打开$size_info1 = getimagesize($img);
// 以字符串格式打开$data       = file_get_contents($img);
$size_info2 = getimagesizefromstring($data);
?>

阅读全文 »

GD 和图像处理 函数 imageaffine 返回经过仿射变换后的图像,剪切区域可选

发表日期:2021-07-01 08:55:56 | 来源: | 分类:GD 和图像处理 函数

imageaffine

(PHP 5 >= 5.5.0, PHP 7, PHP 8)

imageaffine返回经过仿射变换后的图像,剪切区域可选

说明

imageaffine(resource $image, array $affine, array $clip = ?): resource

警告

本函数还未编写文档,仅有参数列表。

参数

image

由图象创建函数(例如imagecreatetruecolor())返回的图象资源。

affine

数组,其中键为 0 至 5 的数字。

clip

数组,其中键为 "x","y","width" 和 "height"。

返回值

成功则返回仿射变换后的图像, 或者在失败时返回 false.

阅读全文 »

GD 和图像处理 函数 image_type_to_mime_type 取得 getimagesize,exif_read_data,exif_thumbnail,exif_imagetype 所返回的图像类型的 MIME 类型

发表日期:2021-07-01 08:55:56 | 来源: | 分类:GD 和图像处理 函数

      示例1
<?php 
header("Content-type: " . image_type_to_mime_type(IMAGETYPE_PNG));
?>

阅读全文 »

GD 和图像处理 函数 image2wbmp 以 WBMP 格式将图像输出到浏览器或文件

发表日期:2021-07-01 08:55:56 | 来源: | 分类:GD 和图像处理 函数

      示例1
<?php 
$file = 'php.jpg';
$image = imagecreatefrompng($file);
header('Content-type: ' . image_type_to_mime(IMAGETYPE_WBMP));
image2wbmp($file);
 // output the stream directly?>

阅读全文 »

全部博文(1580)
集速网 copyRight © 2015-2022 宁ICP备15000399号-1 宁公网安备 64010402001209号
与其临渊羡鱼,不如退而结网
欢迎转载、分享、引用、推荐、收藏。