【发布时间】:2011-05-02 05:10:45
【问题描述】:
我正在尝试将图像制作成具有一定大小而不会失真的缩略图(如果图像是矩形)。
<?php
$sql = mysql_query("SELECT * FROM images ORDER BY date DESC LIMIT 30");
$img = 'img/'; //this is where my files are.
while($row = mysql_fetch_array($sql))
{
$imageName = $img.$row['images'];
$tempImage = imagecreatetruecolor(150,150);
$thumbnail = imagecopyresampled($tempImage,$imageName,0,0,0,0,150,150,150,150);
echo $thumbnail;
?>
<div id='<?php echo $imageID; ?>' class='images' style=''>
<img src='<?php echo $imageName; ?>' style='height:150px;width:150px;'/>
</div>
<?php
}
?>
这就是我的代码现在的样子,我需要一些帮助。我有一个代码:
<img src='<?php echo $imageName; ?>' style='height:150px;width:150px;'/>
只是看看它在高度和宽度样式下的样子,但这当然会显示失真。
当我 echo $thumbnail; 它给我 imagecopyresized() 预期参数错误。
感谢您的帮助:)
【问题讨论】: