first - determine file type
if( eregi( "(.*)\.jpg", $file, $matches) ) {
$image = @imagecreatefromjpeg($file);
}
if( eregi( "(.*)\.bmp", $file, $matches) ) {
$image = @imagecreatefromwbmp($file);
}
if( eregi( "(.*)\.gif", $file, $matches) ) {
$image = @imagecreatefromgif($file);
}
then set the size of the image
$orig_w=ImageSX($image);
$orig_h=ImageSY($image);
// chose the dimension to scale with
//
if( ($orig_h > $orig_w) && isset($h) )
{
$factor = $orig_h / $h;
$w = $orig_w / $factor;
}
else
{
if(isset($w))
{
$factor = $orig_w / $w;
$h = $orig_h / $factor;
}
else
{
// need to scale by height even
// though we should scale by width
// but no wanted width was supplied
$factor = $orig_h / $h;
$w = $orig_w / $factor;
}
}
then copy the image in:
$thumb=ImageCreateTrueColor($w,$h);
ImageCopyResampled($thumb,$image,
0,0,0,0,
$w,$h,
$orig_w,$orig_h);
header("Content-type: image/jpeg");
ImageJPEG($thumb, $thumbname, 100);
readfile($thumbname);
I save the file with the ImageJPEG() function and have this whole thing wrapped to check for the existance of the previously generated file. A cache if you will 🙂 Do you ever find yourself explaining the most basic things to people becasue you're so used to explaining every last thing you do 🙂 I do .... 😕
anyway
so sorry you had to sit through one of my drivel sessions.