 |
 |
 |
 |
 |
| Author |
Message |
chrisw
Joined: 26 Jan 2006 Posts: 2
|
|
Thumbnail |
|
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
|
|
| Sun Jan 29, 2006 4:40 pm |
|
 |
Guest
|
|
|
Please login to hide the ads.
|
|
|
|
 |
FI-DD
Admin

Joined: 22 Sep 2005 Posts: 2801 Location: Germany |
|
|
|
Why don't you use the built-in thumbnail function?
|
|
| Sun Jan 29, 2006 7:49 pm |
|
 |
chrisw
Joined: 26 Jan 2006 Posts: 2
|
|
|
|
Because the standard function does not make that nice thumbnails.
The qauality is not so good as with GD 2.
|
|
| Sun Jan 29, 2006 9:26 pm |
|
 |
FI-DD
Admin

Joined: 22 Sep 2005 Posts: 2801 Location: Germany |
|
|
|
Open images.mdu and change imagecopyresize to imagecopyresampled.
That's it. And you are right, the quality is better.
(I will change this in the download file as well.)
|
|
| Mon Jan 30, 2006 12:48 am |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|
 |
 |
 |
|