开发者

PHP - display thumbnails of images from Mysql

I have a table in my mysql db that contains path for images. I want to display thumbnails of this images. Can you tell me what is the best solution for that. This is how i display the full size images fro开发者_StackOverflow中文版m db:

<?php for($i=1; $i<=5; $i++)
{$query = mysql_query("SELECT * FROM photos WHERE product_id='".$i."'");
$row = mysql_fetch_array($query);
$t="img/";
$file = $t .$row[1];
echo "<li><a href=\"#\"><img src = " . $file . "></a></li>";
} ?>


You can use this http://mightystuff.net/php-thumbnail-script


Either resize the images in css/html (bad) or make a php script that gets a filename as input then returns the scaled down version as output (better) or have thumbnails stored on your server (best)


You should avoid having to resize the images using CSS or HTML. Before saving the images onto the server, you should use ImageMagick to resize it. Do you really want to store a bunch of 6MB images? If that's not feasible, then saving the images as is and pointing to the path would suffice. However, if you end up with hundreds or thousands of images, you'll want to explore a better option.


I agree with the approach of storing the file path (instead of the binary file itself).

So your question is "how do you create a thumbnail?"

The best answer is ImageMagick:

http://www.imagemagick.org/

http://valokuva.org/?p=45

http://php.net/manual/en/book.imagick.php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜