HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

imageresolution

Description

The imageresolution of Image for PHP gets or sets 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

As a getter, it returns an indexed array of the horizontal and vertical resolution on success, or false on failure.

As a 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
)