Forum Index
RegisterSearchFAQMemberlistUsergroupsLog in
Thumbnail

 
Reply to topic    Forum Index » Suggestions View previous topic
View next topic
Thumbnail
Author Message
chrisw



Joined: 26 Jan 2006
Posts: 2

Post Thumbnail Reply with quote
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 View user's profile Send private message
Guest








Please login to hide the ads.

FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2801
Location: Germany

Post Reply with quote
Why don't you use the built-in thumbnail function?
Sun Jan 29, 2006 7:49 pm View user's profile Send private message
chrisw



Joined: 26 Jan 2006
Posts: 2

Post Reply with quote
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 View user's profile Send private message
FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2801
Location: Germany

Post Reply with quote
Open images.mdu and change imagecopyresize to imagecopyresampled.



That's it. And you are right, the quality is better. Wink



(I will change this in the download file as well.)
Mon Jan 30, 2006 12:48 am View user's profile Send private message
Display posts from previous:    
Reply to topic    Forum Index » Suggestions All times are GMT + 1 Hour
Page 1 of 1

 
Jump to: 
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



Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Music Lyrics.