创建缩略图时出现images()和images()错误

时间:2012-01-29 00:10:54

标签: php image-resizing

  

可能重复:
  mysql_fetch_array() expects parameter 1 to be resource, boolean given in select

我想自动为热门帖子创建缩略图。所以我决定调整当前小尺寸的图像,使用它作为tumbnail使用这个 - resize-class.php类并编写如下代码:

// Include the class
include("resize-class.php");

$top_posts = mysql_query("In this query I select top posts - the most viewed posts of the day")
while ($row = mysql_fetch_array($top_posts)){
    $post_id    = $row['post_id']; // defining the ID of the post as variable
    $post_image = $row['post_image']; //defining the image of the post as variable
    //save image
    $resizeObj = new resize($post_image); // Initialise - load image
    $resizeObj -> resizeImage(260, 210, 'exact'); // resizing $post_image with 'exact' option
    $resizeObj -> saveImage('images/'.$post_id.'.jpg', 80); // saving thumbnail of $post_image to the storage
}

但是像这样返回循环中的错误:

Warning: imagesx() expects parameter 1 to be resource, boolean given in resize-class.php on line 34

Warning: imagesy() expects parameter 1 to be resource, boolean given in resize-class.php on line 35

Warning: imagecopyresampled() expects parameter 2 to be resource, boolean given in resize-class.php on line 77

有什么问题?

1 个答案:

答案 0 :(得分:3)

不是$post_image应该是图片的路径吗? 如果它实际上是图像的路径..那么我认为这条路有问题.. 试着回应$post_image并看看你得到了什么......

相关问题