Forum Moderators: coopster

Message Too Old, No Replies

Image Thumbnails

         

Ananthi

6:40 am on Jan 19, 2007 (gmt 0)

10+ Year Member



How to create thumbnails for images dynamically

omoutop

7:11 am on Jan 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You will need the gd library for this (consult your phpinfo and gd_info for further details whether it is enableed in your system or not - it usually is).

Also you will need a lot of various image functions.

I would advice to check various free scripts/classes to see how they work, and then code some script for yourself (to better suit your needs)

cameraman

7:24 am on Jan 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Like omoutop said, if you have gd enabled (probably true), you use the image functions. This page at php.net shows you how to do it:
[php.net ]

steven420

8:42 pm on Jan 19, 2007 (gmt 0)

10+ Year Member



Here is a class that can resize images:

<?php

class resize
{

function resize($width, $height, $target)
{

if ($width > $height)
{
$percentage = ($target / $width);
}
else
{
$percentage = ($target / $height);
}

$width = round($width * $percentage);
$height = round($height * $percentage);

return "width='$width' height='$height'";

}// end function

}// end class

class pic_resize extends resize
{

function pic_resize($img)
{
list($width, $height) = getimagesize($img);
$resize = new resize;
echo '<img src="';
echo $img;
echo '" ';
echo $resize->resize($width, $height, 60);
echo '>';

}// end function

}// end class

?>
then add this to the page:
 <?php 
require('class url');
$picture = new pic_resize("image url");
?>

ahmedtheking

8:50 pm on Jan 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Check out phpThumb: [phpthumb.sourceforge.net...]