PHP GD库imagecopyrezised() [英] php GD Library imagecopyrezised()

查看:63
本文介绍了PHP GD库imagecopyrezised()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下行来调整图像文件的大小:

I am using the following line to resize an image file:

imagecopyresized($dst_image, $dst_image, 0, 0, 0, 0, 1000, 750, $src_w, $src_h

我希望将1000和750的值作为新图像文件的尺寸,但是,将使用与原始文件相同的尺寸来创建图像,然后将该图像的一部分复制回去.

I am expecting the values of 1000 and 750 to be the dimensions of the new image file, but instead, an image is being created with the same dimensions as the original file, and copying a section of this image back onto it.

有人可以帮忙吗?

推荐答案

您应该创建一个新的图像源并将图像复制到其中:

You should create a new image source and copy the image in there:

$resized = imagecreatetruecolor(1000, 750);
imagecopyresized($resized, $dst_image, 0, 0, 0, 0, 1000, 750, $src_w, $src_h)

请参见文档:php.net/imagecopyresized

这篇关于PHP GD库imagecopyrezised()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆