(PECL imagick 2.0.0)
Imagick::scaleImage — Scales the size of an image
$cols
, int $rows
[, bool $bestfit = FALSE
[, bool $legacy = FALSE
]] ) : boolScales the size of an image to the given dimensions. The other parameter will be calculated if 0 is passed as either param.
Nota: O comportamento do parâmetro
bestfitmudou no Imagick 3.0.0. Antes desta versão ao informar dimensões 400x400 numa imagem de 200x150 não causaria alterações. No Imagick 3.0.0 e posteriores a imagem seria escalada para 400x300 por ser o "melhor ajuste" entre as dimensões. Sebestfité informado tanto a altura como comprimento devem ser informados.
cols
rows
bestfit
Retorna TRUE no sucesso.
Lança ImagickException em caso de erro.
| Versão | Descrição |
|---|---|
| 2.1.0 | Added optional fit parameter. This method now supports proportional scaling. Pass zero as either parameter for proportional scaling. |
Exemplo #1 Imagick::scaleImage()
<?php
function scaleImage($imagePath) {
$imagick = new \Imagick(realpath($imagePath));
$imagick->scaleImage(150, 150, true);
header("Content-Type: image/jpg");
echo $imagick->getImageBlob();
}
?>