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

Math 函数 ceil 进一法取整

发表日期:2021-07-01 08:56:06 | 来源: | 分类:Math 函数

      示例1
<?php 
echo ceil(4.3);
    // 5echo ceil(9.999);
  // 10echo ceil(-3.14);
  // -3?>

阅读全文 »

Math 函数 atan2 两个参数的反正切

发表日期:2021-07-01 08:56:05 | 来源: | 分类:Math 函数

atan2

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

atan2两个参数的反正切

说明

atan2(float $y, float $x): float

本函数计算两个变量 xy 的反正切值。和计算 y / x 的反正切相似,只除了两个参数的符号是用来确定结果的象限之外。

本函数的结果为弧度,其值在 -PI 和 PI 之间(包括 -PI 和 PI)。

参数

y

Dividend parameter

x

Divisor parameter

返回值

xy 的反正切弧度值。

参见

阅读全文 »

Math 函数 asinh 反双曲正弦

发表日期:2021-07-01 08:56:05 | 来源: | 分类:Math 函数

asinh

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

asinh反双曲正弦

说明

asinh(float $arg): float

返回 arg 的反双曲正弦值,即,其双曲正弦为 arg 的那个值。

参数

arg

要处理的参数

返回值

返回 arg 的反双曲正弦值

更新日志

版本 说明
5.3.0 此函数在所有平台上均可用

参见

阅读全文 »

Math 函数 asin 反正弦

发表日期:2021-07-01 08:56:05 | 来源: | 分类:Math 函数

asin

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

asin反正弦

说明

asin(float $arg): float

返回 arg 的反正弦值,单位是弧度。asin()sin() 的反函数,它的意思是在 asin() 范围里的每个值都是 a==sin(asin(a))

参数

arg

待处理的参数

返回值

arg 的反正弦弧度。

参见

阅读全文 »

可交换图像信息 exif_thumbnail 取得嵌入在 TIFF 或 JPEG 图像中的缩略图

发表日期:2021-07-01 08:56:03 | 来源: | 分类:可交换图像信息

      示例1
<?php 
if (array_key_exists('file',$_REQUEST)) {
    $image = exif_thumbnail($_REQUEST['file'], $width, $height, $type);
}
 else {
    $image = false;
}
if ($image!==false) {
    header("Content-type: ".image_type_to_mime_type($type));
    echo $image;
    exit;
}
 else {
    // no thumbnail available, handle the error here    echo "No thumbnail available";
}
?>

阅读全文 »

可交换图像信息 read_exif_data 别名 exif_read_data()

发表日期:2021-07-01 08:56:03 | 来源: | 分类:可交换图像信息

read_exif_data

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

read_exif_data别名 exif_read_data()

警告

This alias was DEPRECATED in PHP 7.2.0, and REMOVED as of PHP 8.0.0.

说明

此函数是该函数的别名: exif_read_data().

更新日志

版本 说明
7.2.0 这个函数别名被废弃。

阅读全文 »

GD 和图像处理 函数 imagetruecolortopalette 将真彩色图像转换为调色板图像

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

      示例1
<?php 
// Create a new true color image$im = imagecreatetruecolor(100, 100);
// Convert to palette-based with no dithering and 255 colorsimagetruecolortopalette($im, false, 255);
// Save the imageimagepng($im, './paletteimage.png');
imagedestroy($im);
?>

阅读全文 »

GD 和图像处理 函数 imagesetstyle 设定画线的风格

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

      示例1
<?php 
header("Content-type: image/jpeg");
$im  = imagecreatetruecolor(100, 100);
$w   = imagecolorallocate($im, 255, 255, 255);
$red = imagecolorallocate($im, 255, 0, 0);
/* 画一条虚线,5 个红色像素,5 个白色像素 */
$style = array($red, $red, $red, $red, $red, $w, $w, $w, $w, $w);
imagesetstyle($im, $style);
imageline($im, 0, 0, 100, 100, IMG_COLOR_STYLED);
/* 用 imagesetbrush() 和 imagesetstyle 画一行笑脸 */
$style = array($w, $w, $w, $w, $w, $w, $w, $w, $w, $w, $w, $w, $red);
imagesetstyle($im, $style);
$brush = imagecreatefrompng("http://www.libpng.org/pub/png/images/smile.happy.png");
$w2 = imagecolorallocate($brush, 255, 255, 255);
imagecolortransparent($brush, $w2);
imagesetbrush($im, $brush);
imageline($im, 100, 0, 0, 100, IMG_COLOR_STYLEDBRUSHED);
imagejpeg($im);
imagedestroy($im);
?>

阅读全文 »

GD 和图像处理 函数 imagetypes 返回当前 PHP 版本所支持的图像类型

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

      示例1
<?php 
if (imagetypes() & IMG_PNG) {
    echo "PNG Support is enabled";
}
?>

阅读全文 »

GD 和图像处理 函数 imagettfbbox 取得使用 TrueType 字体的文本的范围

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

imagettfbbox

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

imagettfbbox取得使用 TrueType 字体的文本的范围

说明

imagettfbbox(
    float $size,
    float $angle,
    string $fontfile,
    string $text
): array

本函数计算并返回一个包围着 TrueType 文本范围的虚拟方框的像素大小。

size
像素单位的字体大小。
angle
text 将被度量的角度大小。
fontfile
TrueType 字体文件的文件名(可以是 URL)。根据 PHP 所使用的 GD 库版本,可能尝试搜索那些不是以 '/' 开头的文件名并加上 '.ttf' 的后缀并搜索库定义的字体路径。
text
要度量的字符串。
imagettfbbox() 返回一个含有 8 个单元的数组表示了文本外框的四个角:
0 左下角 X 位置
1 左下角 Y 位置
2 右下角 X 位置
3 右下角 Y 位置
4 右上角 X 位置
5 右上角 Y 位置
6 左上角 X 位置
7 左上角 Y 位置
这些点是相对于文本的而和角度无关,因此“左上角”指的是以水平方向看文字时其左上角。

本函数同时需要 GD 库和 FreeType 库。

参见 imagettftext()

阅读全文 »

GD 和图像处理 函数 imagesy 取得图像高度

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

      示例1
<?php 
// create a 300*200 image$img = imagecreatetruecolor(300, 200);
echo imagesy($img);
 // 200?>

阅读全文 »

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

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

imagewbmp

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

imagewbmp以 WBMP 格式将图像输出到浏览器或文件

说明

imagewbmp(resource $image, string $filename = ?, int $foreground = ?): bool

imagewbmp()image 图像创建一个名为 filenameWBMP 文件。image 参数是 imagecreatetruecolor() 的返回值。

filename 参数是可选项,如果省略,则直接将原图像流输出。通过用 header() 发送 image/vnd.wap.wbmp 的 Content-type,可以创建直接输出 WBMP 图像的 PHP 脚本。

注意:

WBMP 支持仅能用于 PHP 编译时加入了 GD-1.8 或更高版本时。

用可选的 foreground 参数可以设定前景色,用 imagecolorallocate() 函数返回的颜色标识符。默认前景色是黑色。

参见 image2wbmp()imagepng()imagegif()imagejpeg()imagetypes()

阅读全文 »

GD 和图像处理 函数 imagexbm 将 XBM 图像输出到浏览器或文件

发表日期:2021-07-01 08:56:02 | 来源: | 分类: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);
// 保存图像imagexbm($im, 'simpletext.xbm');
// 释放内存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);
// 设置替换的前景色$foreground_color = imagecolorallocate($im, 255, 0, 0);
// 保存图像imagexbm($im, NULL, $foreground_color);
// 释放内存imagedestroy($im);
?>

阅读全文 »

GD 和图像处理 函数 iptcparse 将二进制 IPTC 块解析为单个标记

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

      示例1
<?php 
$size = getimagesize('./test.jpg', $info);
if(isset($info['APP13'])){
    $iptc = iptcparse($info['APP13']);
    var_dump($iptc);
}
?>

阅读全文 »

GD 和图像处理 函数 imagettftext 用 TrueType 字体向图像写入文本

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

      示例1
<?php 
// Set the enviroment variable for GDputenv('GDFONTPATH=' . realpath('.'));
// Name the font to be used (note the lack of the .ttf extension)$font = 'SomeFont';
?>
      示例2
<?php 
// Set the content-typeheader('Content-Type: image/png');
// Create the image$im = imagecreatetruecolor(400, 30);
// Create some colors$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
// The text to draw$text = 'Testing...';
// Replace path by your own font path$font = 'arial.ttf';
// Add some shadow to the textimagettftext($im, 20, 0, 11, 21, $grey, $font, $text);
// Add the textimagettftext($im, 20, 0, 10, 20, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()imagepng($im);
imagedestroy($im);
?>

阅读全文 »

GD 和图像处理 函数 imagewebp 将 WebP 格式的图像输出到浏览器或文件

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

      示例1
<?php 
// 创建一个空图像并在其上加入一些文字$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,  'WebP with PHP', $text_color);
// 保存图像imagewebp($im, 'php.webp');
// 释放内存imagedestroy($im);
?>

阅读全文 »

GD 和图像处理 函数 iptcembed 将二进制 IPTC 数据嵌入到一幅 JPEG 图像中

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

      示例1
<?php 
// iptc_make_tag() function by Thies C. Arntzenfunction iptc_make_tag($rec, $data, $value){
    $length = strlen($value);
    $retval = chr(0x1C) . chr($rec) . chr($data);
    if($length < 0x8000)    {
        $retval .= chr($length >> 8) .  chr($length & 0xFF);
    }
    else    {
        $retval .= chr(0x80) .                    chr(0x04) .                    chr(($length >> 24) & 0xFF) .                    chr(($length >> 16) & 0xFF) .                    chr(($length >> 8) & 0xFF) .                    chr($length & 0xFF);
    }
    return $retval . $value;
}
// Path to jpeg file$path = './phplogo.jpg';
// We need to check if theres any IPTC data in the jpeg image. If there is then // bail out because we cannot embed any image that already has some IPTC data!$image = getimagesize($path, $info);
if(isset($info['APP13'])){
    die('Error: IPTC data found in source image, cannot continue');
}
// Set the IPTC tags$iptc = array(    '2#120' => 'Test image',    '2#116' => 'Copyright 2008-2009, The PHP Group');
// Convert the IPTC tags into binary code$data = '';
foreach($iptc as $tag => $string){
    $tag = substr($tag, 2);
    $data .= iptc_make_tag(2, $tag, $string);
}
// Embed the IPTC data$content = iptcembed($data, $path);
// Write the new image data out to the file.$fp = fopen($path, "wb");
fwrite($fp, $content);
fclose($fp);
?>

阅读全文 »

GD 和图像处理 函数 png2wbmp 将 PNG 图像文件转换为 WBMP 图像文件

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

      示例1
<?php 
// Path to the target png$path = './test.png';
// Get the image sizes$image = getimagesize($path);
// Convert imagepng2wbmp($path, './test.wbmp', $image[1], $image[0], 7);
?>

阅读全文 »

GD 和图像处理 函数 jpeg2wbmp 将 JPEG 图像文件转换为 WBMP 图像文件

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

      示例1
<?php 
// 目标 jpeg 的路径$path = './test.jpg';
// 获取图像尺寸$image = getimagesize($path);
// 转换图像jpeg2wbmp($path, './test.wbmp', $image[1], $image[0], 5);
?>

阅读全文 »

可交换图像信息 exif_read_data 从一个图片文件中读取 EXIF 头信息

发表日期:2021-07-01 08:56:02 | 来源: | 分类:可交换图像信息

      示例1
<?php 
echo "test1.jpg:<br />\n";
$exif = exif_read_data('tests/test1.jpg', 'IFD0');
echo $exif===false ? "No header data found.<br />\n" : "Image contains headers<br />\n";
$exif = exif_read_data('tests/test2.jpg', 0, true);
echo "test2.jpg:<br />\n";
foreach ($exif as $key => $section) {
    foreach ($section as $name => $val) {
        echo "$key.$name: $val<br />\n";
    }
}
?>

      示例2
<?php 
// Open a the file, this should be in binary mode$fp = fopen('/path/to/image.jpg', 'rb');
if (!$fp) {
    echo 'Error: Unable to open image for reading';
    exit;
}
// Attempt to read the exif headers$headers = exif_read_data($fp);
if (!$headers) {
    echo 'Error: Unable to read exif headers';
    exit;
}
// Print the 'COMPUTED' headersecho 'EXIF Headers:' . PHP_EOL;
foreach ($headers['COMPUTED'] as $header => $value) {
    printf(' %s => %s%s', $header, $value, PHP_EOL);
}
?>

阅读全文 »

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