Imagick::resizeImage

(No version information available, might be only in CVS)

Imagick::resizeImage — Scales an image

Описание

bool Imagick::resizeImage ( int $columns , int $rows , int $filter , float $blur [, bool $fit ] )
Внимание

К настоящему времени эта функция еще не была документирована; для ознакомления доступен только список аргументов.

Scales an image to the desired dimensions with a filter.

Список параметров

columns

Width of the image

rows

Height of the image

filter

Refer to the list of filter constants.

blur

The blur factor where > 1 is blurry, < 1 is sharp.

fit

Optional fit paramater. Defaults to false.

Возвращаемые значения

Returns TRUE on success.

Список изменений

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

Коментарии

blur:  > 1 is blurry, < 1 is sharp

To create a nice thumbnail (LANCZOS is the slowest filter):

<?php

$thumb 
= new Imagick();
$thumb->readImage('myimage.gif');    $thumb->resizeImage(320,240,Imagick::FILTER_LANCZOS,1);
$thumb->writeImage('mythumb.gif');
$thumb->clear();
$thumb->destroy(); 

?>

Or, a shorter version of the same:

<?php

$thumb 
= new Imagick('myimage.gif');

$thumb->resizeImage(320,240,Imagick::FILTER_LANCZOS,1);
$thumb->writeImage('mythumb.gif');

$thumb->destroy(); 

?>
2007-08-25 02:08:35
http://php5.kiev.ua/manual/ru/function.imagick-resizeimage.html
<?php
$height
=$thumb->getImageHeight();
$width=$thumb->getImageWidth();
if (
$height $width)
 
$thumb->scaleImage(800,0);
 else
 
$thumb->scaleImage(0,600);
?>

Something like this will cause a fatal error when you try to create a thumbnail of an uploaded picture of.. 10x15000 resolution.

It will work nice only if you enable the 'fit':

<?php
$height
=$thumb->getImageHeight();
$width=$thumb->getImageWidth();
if (
$width 800)
$thumb->scaleImage(800,600,true);
if (
$height 600)
$thumb->scaleImage(800,600,true);
?>

Note: Maybe I misspelled something or though something wrong. i.e. you could think why would I create a thumbnail of 800x600.

Hope it will helps s/o
2008-11-05 21:50:44
http://php5.kiev.ua/manual/ru/function.imagick-resizeimage.html
Having to do alot of resizing, i needed to know the speeds of the different resize filters.
This was how long it took to resize a 5906x5906 JPEG image to 1181x1181.

FILTER_POINT took: 0.334532976151 seconds
FILTER_BOX took: 0.777871131897 seconds
FILTER_TRIANGLE took: 1.3695909977 seconds
FILTER_HERMITE took: 1.35866093636 seconds
FILTER_HANNING took: 4.88722896576 seconds
FILTER_HAMMING took: 4.88665103912 seconds
FILTER_BLACKMAN took: 4.89026689529 seconds
FILTER_GAUSSIAN took: 1.93553304672 seconds
FILTER_QUADRATIC took: 1.93322920799 seconds
FILTER_CUBIC took: 2.58396601677 seconds
FILTER_CATROM took: 2.58508896828 seconds
FILTER_MITCHELL took: 2.58368492126 seconds
FILTER_LANCZOS took: 3.74232912064 seconds
FILTER_BESSEL took: 4.03305602074 seconds
FILTER_SINC took: 4.90098690987 seconds 

I ended up choosing CATROM as it has a very similar result to LANCZOS, but is significantly faster.
2009-11-08 16:32:09
http://php5.kiev.ua/manual/ru/function.imagick-resizeimage.html
Use setImageOpacity(1.0) before resizing, for proper handling of transparency in png and gif.
2009-11-16 15:18:17
http://php5.kiev.ua/manual/ru/function.imagick-resizeimage.html
In our linux environment, using resizeImage with any filter produced extremely high CPU Utilization (in the range of 40-50%) while doing batch resizing.

We switched to scaleImage, which produces similar results to FILTER_BOX, and CPU Utilization dropped to 2-3%. 

Using XHProf to profile the two batch jobs showed amazing decreases in CPU Time, so if you're doing a lot of picture resizing, it might be beneficial to use scaleImage instead of resizeImage, as it seems to be much much more efficient.
2011-04-15 20:37:46
http://php5.kiev.ua/manual/ru/function.imagick-resizeimage.html

    Поддержать сайт на родительском проекте КГБ