[Solved] Thumbnails BUT they lose there quality, badly.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

[Solved] Thumbnails BUT they lose there quality, badly.

Post by Dale »

Ok I have a site (ain't gonna post the link because it's a rude fetish site) and people upload a picture, and it's staus (in the database) going to pending, which is then when I go into my control panel and accept or deny it. If I accept it then it gets the image from teh directory and makes a thumbnail of it. However the thumbnails come out like really dodgy quality.

Example...

Proper image ( me :p - yes a chav ("UK thing") )
Image

Thumbnail
Image

Notice how dodgy the thumbnail is? Now I used a tutorial on a website to make the thumbnails and this is what I'm using.. any ideas on how to make it better??

Code: Select all

<?php
// *snipped other code*

// Make Thumbnail
$src_img = imagecreatefromjpeg("../pics/$thum_filename");
$origw=imagesx($src_img);
$origh=imagesy($src_img);
$new_w = 100;
$new_h=150;
$dst_img = imagecreate($new_w,$new_h);
imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img));
imagejpeg($dst_img, "../thumbs/th_$thum_filename", 100);
echo "Image Approved and has been made public. ";
return true;
?>
Last edited by Dale on Tue Aug 08, 2006 11:23 am, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

imagecreate() :arrow: imagecreatetruecolor()
imagecopyresized() :arrow: imagecopyresampled()

Do some math to get the image into proportions.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

:lol: Chav

(They say Charva in Newcastle)

j/k
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

d11wtq wrote::lol: Chav

(They say Charva in Newcastle)

j/k
Yeah, as far as I know there is Chav, Scally and Charva. :)





Oh and Cheers feyd! :D
Post Reply