PHP | Imagick sampleImage() Function Last Updated : 06 Dec, 2019 Comments Improve Suggest changes Like Article Like Report The Imagick::sampleImage() function is an inbuilt function in PHP which is used to scale an image to the desired dimensions with pixel sampling.This method does not introduce any additional color into the scaled image like other resizing methods. Syntax: bool Imagick::sampleImage( int $rows, int $columns ) Parameters: This function accepts two parameters as mentioned above and described below: $rows: It specifies the height. $columns: It specifies the width. Return Value: This function returns TRUE on success. Exceptions: This function throws ImagickException on error. Below given programs illustrate the Imagick::sampleImage() function in PHP: Program 1: php <?php // Create a new imagick object $imagick = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); // Sample the image $imagick->sampleImage(300, 300); // Display the image header("Content-Type: image/png"); echo $imagick->getImageBlob(); ?> Output: Program 2: php <?php // Create a new imagick object $imagick = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); // Sample the image $imagick->sampleImage(400, 300); // Display the image header("Content-Type: image/png"); echo $imagick->getImageBlob(); ?> Output: Reference: https://www.php.net/manual/en/imagick.sampleimage.php Comment More infoAdvertise with us Next Article PHP | Imagick sampleImage() Function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Imagick Similar Reads PHP | Imagick scaleImage() Function The Imagick::scaleImage() function is an inbuilt function in PHP which is used to scale the size of an image to the given dimensions. Syntax: bool Imagick::scaleImage( int $cols, int $rows, bool $bestfit = false, bool $legacy = false ) Parameters: This function accepts four parameters as mentioned a 2 min read PHP | Imagick spliceImage() Function The Imagick::spliceImage() function is an inbuilt function in PHP which is used to splices a solid color into the image. Syntax: bool Imagick::spliceImage( $width, $height, $x, $y ) Parameters: This function accepts four parameters as mentioned above and described below: $width: This parameter is us 1 min read PHP | Imagick::shaveImage() Function The Imagick::shaveImage() function is an inbuilt function in PHP which is used to shaves pixels from the image edges. It allocates the memory necessary for the new Image structure and returns a pointer to the new image. Syntax: bool Imagick::shaveImage( $columns, $rows ) Parameters: This function ac 1 min read PHP | Imagick spreadImage() Function The Imagick::spreadImage() function is an inbuilt function in PHP which randomly displaces each pixel in a block. It is a special effects method that randomly displaces each pixel in a block defined by the radius parameter. Syntax: bool Imagick::spreadImage( $radius ) Parameters: This function accep 1 min read PHP | Imagick waveImage() Function The Imagick::waveImage() function is an inbuilt function in PHP which is used to create the wave filter in an image. This function is available in the version 6.2.9 or newer. Syntax: bool Imagick::waveImage( $amplitude, $length ) Parameters: This function accepts two parameters as mentioned above an 1 min read Like