我正在研究图像调整器,为我的页面创建缩略图。该调整器的工作原理包括一个直接链接到图像。但是我想要做的就是在URL字符串中放入PHP变量,以便它指向该文件并相应地调整其大小。将变量从一个PHP文件传递到另一个
我的代码如下:
<img src="thumbnail.php?image=<?php echo $row_select_property['image_url']; ?>
调整图片大小:
<?php
// Resize Image To A Thumbnail
// The file you are resizing
$image = '$_GET[image_url]';
//This will set our output to 45% of the original size
$size = 0.45;
// This sets it to a .jpg, but you can change this to png or gif
header('Content-type: image/jpeg');
// Setting the resize parameters
list($width, $height) = getimagesize($image);
$modwidth = $width * $size;
$modheight = $height * $size;
// Creating the Canvas
$tn= imagecreatetruecolor($modwidth, $modheight);
$source = imagecreatefromjpeg($image);
// Resizing our image to fit the canvas
imagecopyresized($tn, $source, 0, 0, 0, 0, $modwidth, $modheight, $width, $height);
// Outputs a jpg image, you could change this to gif or png if needed
imagejpeg($tn);
?>
我所试图做的是传递变量“形象=”以缩略图的脚本。目前我通过URL字符串传递它,但它似乎不加载图形。
如果您有任何问题,我会尽量扩展此内容,因为我觉得有点难以解释。
在此先感谢。
1.您不能在文件之间传递变量。 2.查询字符串中没有`image_url`参数。 3.``$ _GET [image_url]'`literal包含字符串`$ _GET [image_url]`,这是非常无用的 – 2011-01-26 12:18:37