imagescale

(PHP 5 >= 5.5.0, PHP 7)

imagescaleScale an image using the given new width and height

说明

imagescale ( resource $image , int $new_width [, int $new_height = -1 [, int $mode = IMG_BILINEAR_FIXED ]] ) : resource

imagescale() scales an image using the given interpolation algorithm.

Note:

Unlike many of other image functions, imagescale() does not modify the passed image; instead, a new image is returned.

参数

image

由图象创建函数(例如imagecreatetruecolor())返回的图象资源。

new_width

The width to scale the image to.

new_height

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

Caution

You should always provide the height if using PHP 5.5.18 or earlier, or PHP 5.6.2 or earlier, as the aspect ratio calculation was incorrect.

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 the scaled image resource on success 或者在失败时返回 FALSE.

更新日志

版本 说明
5.5.19/5.6.3 The calculation of the height if new_height was negative or omitted was fixed; prior to these versions, the aspect ratio was not maintained correctly.

参见

imagecopyresized() - 拷贝部分图像并调整大小 imagecopyresampled() - 重采样拷贝部分图像并调整大小

相关文章
php classkit 函数 dynamically adds a new method to a given classphp gd 和图像处理 函数 取得图像类型的文件后缀php gd 和图像处理 函数 output a bmp image to browser or filephp gd 和图像处理 函数 取得与指定的颜色最接近的颜色的索引值php gd 和图像处理 函数 取得与指定的颜色加透明度最接近的颜色php gd 和图像处理 函数 用灰度拷贝并合并图像的一部分php gd 和图像处理 函数 新建一个真彩色图像php gd 和图像处理 函数 crop an image to the given rectanglephp gd 和图像处理 函数 crop an image automatically using one of the available modesphp gd 和图像处理 函数 flips an image using a given modephp gd 和图像处理 函数 给出一个使用 freetype 2 字体的文本框php gd 和图像处理 函数 将调色板从一幅图像拷贝到另一幅php gd 和图像处理 函数 converts a palette based image to true colorphp gd 和图像处理 函数 get or set the resolution of the imagephp gd 和图像处理 函数 scale an image using the given new width and heightphp gd 和图像处理 函数 设定画线用的画笔图像php gd 和图像处理 函数 将 webp 格式的图像输出到浏览器或文件php xmlwriter 函数 create new xmlwriter using memory for string outputphp xmlwriter 函数 create new xmlwriter using source uri for outputphp swftext writes the given text into this swftext object at the current pen position using the current font height spacing and color
关注编程学问公众号