<?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
Imagick::resizeImage
(No version information available, might be only in CVS)
Imagick::resizeImage — 画像のサイズを変更する
説明
bool Imagick::resizeImage
( int $columns
, int $rows
, int $filter
, float $blur
[, bool $fit
] )
警告
この関数は、 現在のところ詳細な情報はありません。引数のリストのみが 記述されています。
指定した大きさと フィルタ で、画像のサイズを変更します。
パラメータ
- columns
-
画像の幅。
- rows
-
画像の高さ。
- filter
-
フィルタ定数 の一覧を参照ください。
- blur
-
blur 要素。> 1 はぼやけた状態、< 1 はシャープな状態を表します。
- fit
-
オプションの fit パラメータ。デフォルトは false。
返り値
成功した場合に TRUE を返します。
変更履歴
| バージョン | 説明 |
|---|---|
| 2.1.0 | オプションのパラメータ fit が追加され、 このメソッドは、比例形式の拡大・縮小をサポートするようになりました。 どちらかのパラメータにゼロを渡すと比例形式の拡大・縮小を行います。 |
Imagick::resizeImage
billadoid [at ' at '] ['gmail' here] dot com
05-Nov-2008 09:50
05-Nov-2008 09:50
andrabr at gmail dot com
25-Aug-2007 02:08
25-Aug-2007 02:08
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();
?>
