Hello,
I would like to make thumbnails with gd1 or 2.
I have the code to do this but i don't know how to implement this in images.mdu
Can someone help?
Code:
<?php
function make_thumb ($img_src, $img_th)
{
// some configuration, please match to your server settings
$gd_version = 2;
$thumb_on = 'x';
$thumb_size = 100;
$quality = 30;
$img_size = GetImageSize ($img_src);
$img_in = ImageCreateFromJPEG ($img_src);
if ($thumb_on == 'y')
{
$img_x = ($thumb_size/$img_size[1]) * $img_size[0];
$img_y = $thumb_size;
}
else
{
$img_y = ($thumb_size/$img_size[0]) * $img_size[1];
$img_x = $thumb_size;
}
if ($gd_version == '1')
{
$img_out = ImageCreate($img_x, $img_y);
ImageCopyResized ($img_out, $img_in, 0, 0, 0, 0, $img_x, $img_y, $img_size[0], $img_size[1]);
}
elseif ($gd_version == '2')
{
$img_out = ImageCreateTrueColor($img_x, $img_y);
ImageCopyResampled ($img_out, $img_in, 0, 0, 0, 0, $img_x, $img_y, $img_size[0], $img_size[1]);
}
ImageJPEG ($img_out, $img_th, $quality);
ImageDestroy ($img_out);
ImageDestroy ($img_in);
}
if (isset ($_FILES['image']['name']))
{
$fn = $_FILES['image']['name'];
$src = 'images/'.$fn;
$th = 'thumbs/'.$fn;
if (!@move_uploaded_file ($_FILES['image']['tmp_name'], $src)) die ('Can not upload file...');
make_thumb ($src, $th);
echo "Done!<BR>Original Image:<img src=\"$src\"><BR>Thumbnail Image:<img src=\"$th\">";
}
?>
<form name="form" id="form" action="$PHP_SELF?mod=images" method="post" enctype="multipart/form-data">Thumbnail this file: <input name="image" type="file"><input type="submit" value="Send File"></form>
Regards,
Chris
