首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

imageresolution

(PHP 7 >= 7.2.0)

imageresolution - 获取或设置图像的分辨率

描述

代码语言:javascript
复制
mixed imageresolution ( resource $image [, int $res_x [, int $res_y ]] )

imageresolution()允许设置和获得DPI(每英寸点数)图像的分辨率。如果没有给出任何可选参数,则当前分辨率将作为索引数组返回。如果仅res_x给出,则水平和垂直分辨率设置为该值。如果给出两个可选参数,则分别将水平和垂直分辨率设置为这些值。

只有当图像从支持这种信息的格式中被读取和写入时,分辨率才被用作元信息(PNG和JPEG)。它不影响任何绘图操作。新图像的默认分辨率为96 DPI。

参数

代码语言:txt
复制
`image`   

一个图像资源,由图像创建函数之一返回,如imagecreatetruecolor()。

res_x

DPI中的水平分辨率。

res_y

DPI中的垂直分辨率。

返回值

当用作getter(没有可选参数)时,它会TRUE在成功或FALSE失败时返回。当作为setter使用(即给定一个或两个可选参数)时,它会返回成功或FALSE失败时水平和垂直分辨率的索引数组。

例子

Example #1 Setting and getting the resolution of an image

代码语言:javascript
复制
<?php
$im = imagecreatetruecolor(100, 100);
imageresolution($im, 200);
print_r(imageresolution($im));
imageresolution($im, 300, 72);
print_r(imageresolution($im));
?>

上面的例子将输出:

代码语言:javascript
复制
Array
(
    [0] => 200
    [1] => 200
)
Array
(
    [0] => 300
    [1] => 72
)

← imagerectangle

imagerotate →

扫码关注腾讯云开发者

领取腾讯云代金券