imagescale

FunctionParams and return types changed in PHP 8.0

Scale an image using the given new width and height.

PHP 5.3-5.4
PHP 5.5
Added
PHP 5.6
PHP 7
PHP 8.0
Improved
PHP 8.1
PHP 8.2-8.3
PHP 8.4
PHP 8.5
PHP 8.6

imagescale Function synopsis

imagescale(
    GdImage $image,
    int $width,
    int $height = -1,
    int $mode = IMG_BILINEAR_FIXED
  ): GdImage|false

Parameters

$image

TypeGdImage

$width

Typeint

The width to scale the image to.

$height

OptionalTypeintDefault value-1

The height to scale the image to. If omitted or negative, the aspect ratio will be preserved.

$mode

OptionalTypeintDefault valueIMG_BILINEAR_FIXED

One of IMG_NEAREST_NEIGHBOUR, IMG_BILINEAR_FIXED, IMG_BICUBIC, IMG_BICUBIC_FIXED or anything else (will use two pass).

Return value

TypeGdImage|false

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

Changes to the imagescale Function

PHP 8.0

  • Return type added: GdImage|false
  • Parameter name of parameter #1 changed: $im to $image
  • Parameter type added for parameter #1 ($image): GdImage
  • Parameter name of parameter #2 changed: $new_width to $width
  • Parameter type added for parameter #2 ($width): int
  • Parameter name of parameter #3 changed: $new_height to $height
  • Parameter type added for parameter #3 ($height): int
  • Parameter default value added for position #3 ($height): -1
  • Parameter type added for parameter #4 ($mode): int
  • Parameter default value added for position #4 ($mode): IMG_BILINEAR_FIXED
  imagescale(
-     $im,
+     GdImage $image,
-     $new_width,
+     int $width,
-     $new_height,
+     int $height = -1,
-     $mode
+     int $mode = IMG_BILINEAR_FIXED
-   )
+   ): GdImage|false

PHP 5.5

  • Function added

imagescale Function Availability

PHP VersionAvailability
PHP 8.6Upcoming Release Yes
PHP 8.5Supported (Latest) Yes
PHP 8.4Supported Yes
PHP 8.3Security-Fixes Only Yes
PHP 8.2Security-Fixes Only Yes
PHP 8.1Unsupported Yes
PHP 8.0Unsupported Yes
PHP 7.4Unsupported Yes
PHP 7.3Unsupported Yes
PHP 7.2Unsupported Yes
PHP 7.1Unsupported Yes
PHP 7.0Unsupported Yes
PHP 5.6Unsupported Yes
PHP 5.5Unsupported Yes
PHP 5.4Unsupported No
PHP 5.3Unsupported No