{site_name}

{site_name}

🌜 搜索

Imagick::setImageExtent is a method in P

php 𝄐 0
phpimagick完整安装
Imagick::setImageExtent is a method in PHP's Imagick extension that allows you to set the size (width and height) of an image.

Here is an example of how you can use Imagick::setImageExtent:

php
$image = new Imagick('path/to/image.jpg');

// Set the new size
$newWidth = 500;
$newHeight = 300;
$image->setImageExtent($newWidth, $newHeight);

// Save the modified image
$image->writeImage('path/to/modified_image.jpg');


In this example, we create a new Imagick object using an existing image file. We then set the new width and height using the setImageExtent method. Finally, we save the modified image using the writeImage method.

Note that the dimensions specified in setImageExtent will be the exact dimensions of the image after resizing. If the aspect ratio of the original image is not the same as the specified dimensions, the image may be stretched or squished to fit the new dimensions.

I hope this helps clarify the usage of Imagick::setImageExtent in PHP. Let me know if you have any further questions!