Imagick::thumbnailImage

(PECL imagick 2.0.0)

Imagick::thumbnailImageChanges the size of an image

Descrierea

Imagick::thumbnailImage ( int $columns , int $rows [, bool $bestfit = FALSE [, bool $fill = FALSE [, bool $legacy = FALSE ]]] ) : bool

Changes the size of an image to the given dimensions and removes any associated profiles. The goal is to produce small, low cost thumbnail images suited for display on the Web. If TRUE is given as a third parameter then columns and rows parameters are used as maximums for each side. Both sides will be scaled down until they match or are smaller than the parameter given for the side.

Notă: Comportamentul parametrului bestfit s-a schimbat în Imagick 3.0.0. Anterior acestei versiuni în cazul dimensiunilor 400x400, o imagine cu dimensiunile 200x150 ar fi rămas neschimbată. În Imagick 3.0.0 și versiunile ulterioare imaginea va fi mărită la dimensiunile 400x300 deoarece aceasta este "cea mai bună potrivire" pentru dimensiunile date. Dacă parametrul bestfit este utilizat, trebuie furnizate atât lățimea, cât și înălțimea.

Parametri

columns

Image width

rows

Image height

bestfit

Whether to force maximum values

Valorile întoarse

Întoarce TRUE în caz de succes.

Erori/Excepții

Emite ImagickException în caz de eroare.

Exemple

Example #1 Imagick::thumbnailImage()

<?php
function thumbnailImage($imagePath) {
    
$imagick = new \Imagick(realpath($imagePath));
    
$imagick->setbackgroundcolor('rgb(64, 64, 64)');
    
$imagick->thumbnailImage(100100truetrue);
    
header("Content-Type: image/jpg");
    echo 
$imagick->getImageBlob();
}

?>