array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'uk', ), 'this' => array ( 0 => 'imagick.scaleimage.php', 1 => 'Imagick::scaleImage', 2 => 'Scales the size of an image', ), 'up' => array ( 0 => 'class.imagick.php', 1 => 'Imagick', ), 'prev' => array ( 0 => 'imagick.sampleimage.php', 1 => 'Imagick::sampleImage', ), 'next' => array ( 0 => 'imagick.segmentimage.php', 1 => 'Imagick::segmentImage', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/imagick/imagick/scaleimage.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>

Imagick::scaleImage

(PECL imagick 2, PECL imagick 3)

Imagick::scaleImageScales the size of an image

Опис

public Imagick::scaleImage(
    int $columns,
    int $rows,
    bool $bestfit = false,
    bool $legacy = false
): bool

Scales the size of an image to the given dimensions. The other parameter will be calculated if 0 is passed as either param.

Зауваження: Поведінка параметра bestfit змінилася в Imagick 3.0.0. Раніше він не діяв на зображення розмірів 400x400 та 200x150. Починаючи з Imagick 3.0.0, такі зображення отримають розмір 400x300, оскільки це "найкраще підходить" для заданих розмірів. Якщо параметр bestfit використовується, необхідно вказати як висоту, так і ширину.

Параметри

columns

rows

bestfit

Значення, що повертаються

Повертає true в разі успіху.

Помилки/виключення

Кидає ImagickException в разі помилки.

Журнал змін

Версія Опис
PECL imagick 2.1.0 Added optional fit parameter. This method now supports proportional scaling. Pass zero as either parameter for proportional scaling.

Приклади

Приклад #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();
}

?>