【发布时间】:2013-11-25 01:41:03
【问题描述】:
我终于能够完成多图像调整器的脚本,目前它将原始图像调整为其他 3 种尺寸,但我无法弄清楚如何设置原始高度和宽度。我使用了getimagesize(),但它似乎不起作用。
整个代码都在这里,但我认为没有必要在这里发布所有代码。 http://pastebin.com/UR75tdj3
我已执行以下操作来设置我希望它们调整大小的每个图像的高度和宽度。
$uploadedfile = $_FILES['file']['tmp_name'];
list($width,$height)= getimagesize($uploadedfile);
#large
$largeWidth = 670;
$largeHeight = 330;
$largeTmp = imagecreatetruecolor($largeWidth, $largeHeight);
#medium
$mediumwidth = 330;
$mediumheight = 330;
$mediumTmp = imagecreatetruecolor($mediumWidth,$mediumHeight);
#small
$smallWidth = 327;
$smallHeight = 158;
$smallTmp = imagecreatetruecolor($smallWidth,$smallHeight);
但我也想将原始文件输入到另一个文件夹中,所以我做了以下操作,认为getimagesize($_FILES['file']['tmp_name']) 会正确返回它们,但事实并非如此。
#original
$originalWidth = $width; //here and
$originalHeight = $height; // here
$originalTmp = imagecreatetruecolor($originalWidth,$originalHeight);
那么我如何获得我上面尝试做的原始图像高度和宽度?
$originalWidth 和 $originalHeight 应该返回特定的图像宽度和高度,但它没有,这是我遇到的唯一问题。
【问题讨论】:
-
你为什么不简单地复制原件而不是处理它?复制从图像处理中占用的资源要少得多。
标签: php