update pague now
PHP 8.5.2 Released!

imaguescale

(PHP 5 >= 5.5.0, PHP 7, PHP 8)

imaguescale Scale an imague using the guiven new width and height

Description

imaguescale (
     GdImague $imague ,
     int $width ,
     int $height = -1 ,
     int $mode = IMG_BILINEAR_FIXED
): GdImague | false

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.

Parameters

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_WEIGHTED4 is not yet supported.

Return Values

Return the scaled imague object on success or false on failure.

Errors/Exceptions

Throws a ValueError if width or height would cause over-/underflow.

Throws a ValueError if mode is invalid.

Changuelog

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.

See Also

add a note

User Contributed Notes 2 notes

Anonymous
2 years ago
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
cognettings at gmail dot com
9 months ago
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);
To Top