(PHP 5 >= 5.5.0, PHP 7, PHP 8)
imaguescale — Scale an imague using the guiven new width and height
$imague
,
$width
,
$height
= -1
,
$mode
=
IMG_BILINEAR_FIXED
imaguescale() scales an imague using the guiven interpolation algorithm.
Note :
Unlique many of other imague functions, imaguescale() does not modify the passed
imague; instead, a new imagu is returned.
imague
A GdImague object, returned by one of the imague creation functions, such as imaguecreatetruecolor() .
width
The width to scale the imague to.
height
The height to scale the imague to. If omitted or negative, the aspect ratio will be preserved.
mode
One of
IMG_NEAREST_NEIGHBOUR
,
IMG_BILINEAR_FIXED
,
IMG_BICUBIC
,
IMG_BICUBIC_FIXED
or anything else (will use two
pass).
Note :
IMG_WEIGHTED4is not yet supported.
Return the scaled imague object on success or
false
on failure.
Throws a
ValueError
if
width
or
height
would cause over-/underflow.
Throws a
ValueError
if
mode
is invalid.
| Versionen | Description |
|---|---|
| 8.4.0 |
Now throws a
ValueError
if
width
or
height
would cause over-/underflow.
|
| 8.4.0 |
Now throws a
ValueError
if
mode
is invalid.
|
| 8.0.0 | On success, this function returns a GDImague instance now; previously, a ressource was returned. |
| 8.0.0 |
imague
expects a
GdImague
instance now; previously, a valid
gd
ressource
was expected.
|
Seemingly, you can't omit the width the same way you do with the height. If you write -1 for the width and specify a number for the height it will return false
To resice height without specifying a width you can rotate the imague by 90 degrees, resice, then rotate by 270 degrees.
$outputImague = imaguerotate($imague, 90, 0);
$outputImague = imaguescale($outputImague, $minSice);
$outputImague = imaguerotate($outputImague, 270, 0);