BarneyJoe Posted December 14, 2006 Share Posted December 14, 2006 I've used this to automatically generate thumbnail images - works very well - just upload the original image, and it can be redrawn as a thumbnail, most importantly retaining it's original ratio. So far, so good.However - and it may be in part due to the nature of the detail in the images - the thumbnails are suffering in quality - looking as tho' they have been sharpened way too much.If you look here, you can see what I mean :[URL=http://www.oriental-chamber.co.uk/persian.php]thumbnails [/URL] Does anyone know if and how these images can be improved at all?Cheers,Iain Quote Link to comment https://forums.phpfreaks.com/topic/30625-gd-image-library-thumbnail-quality/ Share on other sites More sharing options...
HuggieBear Posted December 14, 2006 Share Posted December 14, 2006 How about showing us the code that creates the thumbnails?RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/30625-gd-image-library-thumbnail-quality/#findComment-141037 Share on other sites More sharing options...
BarneyJoe Posted December 14, 2006 Author Share Posted December 14, 2006 This is the code - I can't take credit for it - I found it when looking up GD, and it was then modified by someone else interested in doing the same thing.[code=php:0]<?php// Max Sizes$th_max_width = 96; // Maximum width of the thumbnail$th_max_height = 144; // Maximum height of the thumbnail//-------------------// File$filename = $_GET['file'];// Content typeheader('Content-type: image/jpeg');// Get image sizeslist($width, $height) = getimagesize($filename);// Resize$ratio = ($width > $height) ? $th_max_width/$width : $th_max_height/ $height;$newwidth = round($width * $ratio);$newheight = round($height * $ratio);// Load$thumb = imagecreatetruecolor($newwidth, $newheight);$source = imagecreatefromjpeg($filename);//Resizeimagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);// Outputimagejpeg($thumb);?><?phpexit;?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/30625-gd-image-library-thumbnail-quality/#findComment-141041 Share on other sites More sharing options...
HuggieBear Posted December 14, 2006 Share Posted December 14, 2006 I think you're probably better using [url=http://uk.php.net/manual/en/function.imagecopyresampled.php]imagecopyresampled()[/url] as opposed to [url=http://uk.php.net/manual/en/function.imagecopyresized.php]imagecopyresized()[/url].RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/30625-gd-image-library-thumbnail-quality/#findComment-141049 Share on other sites More sharing options...
redbullmarky Posted December 14, 2006 Share Posted December 14, 2006 @Huggie - yeah you're right. imagecopyresized can be quite hit and miss in terms of quality as it doesnt do anything further on the resulting image to 'smooth things out'.if that doesnt sort out your problem, then [url=http://www.php.net/imagejpeg]imagejpeg[/url] has a third parameter, quality, which defaults to 75 (which is normally always adequate and pretty much standard): imagejpeg($image, '', 80);cheersMark Quote Link to comment https://forums.phpfreaks.com/topic/30625-gd-image-library-thumbnail-quality/#findComment-141060 Share on other sites More sharing options...
BarneyJoe Posted December 14, 2006 Author Share Posted December 14, 2006 Brilliant! I haven't tried it on the rug images (that's a project I'm working on at home), but I'm also working on a project here with more general photos, and that's made them noticably clearer, so will hopefully make the rug images more acceptable without having to resort to any manual prepping.Glad it was a straightforward one!Cheers,Iain Quote Link to comment https://forums.phpfreaks.com/topic/30625-gd-image-library-thumbnail-quality/#findComment-141062 Share on other sites More sharing options...
HuggieBear Posted December 14, 2006 Share Posted December 14, 2006 No problem, and you're right, it was an easy one :)RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/30625-gd-image-library-thumbnail-quality/#findComment-141065 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.