imageresolution

Get or set the resolution of the image

Syntax

imageresolution(
    GdImage $image,
    ?int $resolution_x = null,
    ?int $resolution_y = null
): array|bool

Parameters

image

A GdImage object, returned by one of the image creation functions, such as imagecreatetruecolor().

resolution_x

The horizontal resolution in DPI.

resolution_y

The vertical resolution in DPI.

Return

When used as getter, it returns an indexed array of the horizontal and vertical resolution on success, or false on failure. When used as setter, it returns true on success, or false on failure.

Examples

1 · image

<?

$width = 100;
$height = 100;
$image = imagecreate($width, $height);

$return = imageresolution($image);

print_r($return);

?>
Array
(
    [0] => 96
    [1] => 96
)

2 · resolution_x

<?

$width = 100;
$height = 100;
$image = imagecreate($width, $height);

$resolution_x = 192;

$return = imageresolution($image, $resolution_x);

var_export($return);

$resolution = imageresolution($image);

echo PHP_EOL;
print_r($resolution);

?>
true
Array
(
    [0] => 192
    [1] => 192
)

3 · resolution_y

<?

$width = 100;
$height = 100;
$image = imagecreate($width, $height);

$resolution_x = 192;
$resolution_y = 96;

$return = imageresolution($image, $resolution_x, $resolution_y);

var_export($return);

$resolution = imageresolution($image);

echo PHP_EOL;
print_r($resolution);

?>
true
Array
(
    [0] => 192
    [1] => 96
)

gd_info

getimagesize

getimagesizefromstring

image_type_to_extension

image_type_to_mime_type

imageaffine

imageaffinematrixconcat

imageaffinematrixget

imagealphablending

imageantialias

imagearc

imageavif

imagebmp

imagechar

imagecharup

imagecolorallocate

imagecolorallocatealpha

imagecolorat

imagecolorclosest

imagecolorclosestalpha

imagecolorclosesthwb

imagecolordeallocate

imagecolorexact

imagecolorexactalpha

imagecolormatch

imagecolorresolve

imagecolorresolvealpha

imagecolorset

imagecolorsforindex

imagecolorstotal

imagecolortransparent

imageconvolution

imagecopy

imagecopymerge

imagecopymergegray

imagecopyresampled

imagecopyresized

imagecreate

imagecreatefromavif

imagecreatefrombmp

imagecreatefromgif

imagecreatefromjpeg

imagecreatefrompng

imagecreatefromstring

imagecreatefromtga

imagecreatefromwbmp

imagecreatefromwebp

imagecreatefromxbm

imagecreatefromxpm

imagecreatetruecolor

imagecrop

imagecropauto

imagedashedline

imagedestroy

imageellipse

imagefill

imagefilledarc

imagefilledellipse

imagefilledpolygon

imagefilledrectangle

imagefilltoborder

imagefilter

imageflip

imagefontheight

imagefontwidth

imageftbbox

imagefttext

imagegammacorrect

imagegetclip

imagegetinterpolation

imagegif

imageinterlace

imageistruecolor

imagejpeg

imagelayereffect

imageline

imageloadfont

imageopenpolygon

imagepalettecopy

imagepalettetotruecolor

imagepng

imagepolygon

imagerectangle

imagerotate

imagesavealpha

imagescale

imagesetbrush

imagesetclip

imagesetinterpolation

imagesetpixel

imagesetstyle

imagesetthickness

imagesettile

imagestring

imagestringup

imagesx

imagesy

imagetruecolortopalette

imagettfbbox

imagettftext

imagetypes

imagewbmp

imagewebp

imagexbm

iptcembed

iptcparse

HomeMenu