Syntax:bool Imagick::setResolution (float $x_resolution, float $y_resolution)
Parameters:This function takes two parameters as above and described below: - $x_resolution: specifies the horizontal resolution.
- $y_resolution:specifies the vertical resolution.
Return value: this function returns TRUE on success.Exceptions:this function throws an ImagickException on error.The following programs illustrate the Imagick::setResolution function()in PHP:Program 1:
// Create a new imagick object
$imagick
=
new
Imagick();
// Set permission
$imagick
-> setResolution (18, 13);
// Create new image
$imagick
-> newimage (100, 100,
’none’
);
// Read image properties
print
(
"
"
. print_r (
$imagick
-> identifyImage(), true).
"
"
);
?>
Output: Array
(
[imageName] = >
[mimetype] = > image / x-
[units] = > Undefined
[type] = > Bilevel
[colorSpace] = > sRGB
[compression] = > Undefined
[fileSize] = > 0B
[geometry] = > Array
(
[width] = > 100
[height] = > 100
)
// you can see the temporary resolution here
[resolution] = > Array
(
[x] = > 18
[y] = > 13
)[signature ] = > e7e2dcff542de95352682dc186432e98f0188084896773f1973276b0577d5305
) Program 2:
// Create a new imagick object
$imagick
=
new
Imagick();
// Set permission
$imagick
-> setResolution (10, 10);
// Reading the image
$imagick
-> readimage (
’ https://media.engineerforengineer.org/wp-content /uploads/engineerforengineer-13.png ’
);
// Read image properties
print
(
"
"
. print_r (
$imagick
-> identifyImage(), true).
"
"
);
?>
Output:
Array
(
[imageName] = >
[mimetype] = > image / png
[format] = > PNG (Portable Network Graphics)
[units] = > PixelsPerCentimeter
[type] = > TrueColorAlpha
[colorSpace] = > sRGB
[compression] = > Zip
[fileSize] = > 45.4KB
[geometry] = > Array
(
[width] = > 667
[height] = > 184
)
// Here resolution is changed because new image is read
[resolution] = > Array
(
[x] = > 37.8
[y] = > 37.8
)[signature] = > f64054f5bcb4cfb82c6126eff6d3d4e6be7d0e72d5620033442cecb4b9feabbd
) Link a:= : //www.php.net/manual/en/imagick.setresolution.php> https://www.php.net/manual/en/imagick.setresolution.php