jonw118 Posted August 18, 2007 Share Posted August 18, 2007 I have a new website where the thumb images display VERY poorly. I want the images to display clearly. I think it has something to do with the $thumbfactor, but as I change it, doesn't help the quality. Can someone look at this and see if you see any setting you would change to make the thumb images not so grainy/pixelated? Thanks much in advance: function getImage($srcImg,$typImg){ switch($typImg){ case 1://Thumb $cStr = "th_"; break; case 2://Prev $cStr = "pr_"; nreak; } $abc = explode("/",$srcImg); $thumbName = $cStr.$abc[count($abc)-1]; $abc[count($abc)-1] = $thumbName; $abc = implode("/",$abc); return $abc; } function aspectRatio($width, $height ,$thumbFactor){ //-------Image Manipulation Constants---// $thumbFactor = 110; $imageThumbPrefix = "th_"; //-------------------------------------// if ($width > $height){ $retWidth = $thumbFactor; $retHeight = $thumbFactor * ($height / $width); } elseif ($width < $height){ $retHeight = 82; $retWidth = $thumbFactor * $width / $height; } elseif ($width==$height){ $retWidth = $thumbFactor; $retHeight = 82 ; } else die ("unknown scenario"); $outStr = $retWidth.",".$retHeight; // $outStr = "100,100"; return $outStr; } function aspectRatio_user($width, $height ,$thumbFactor){ //-------Image Manipulation Constants---// $thumbFactor = 115; $imageThumbPrefix = "th_"; //-------------------------------------// if ($width > $height){ $retWidth = $thumbFactor; $retHeight = $thumbFactor * ($height / $width); } elseif ($width < $height){ $retHeight = $thumbFactor; $retWidth = $thumbFactor * $width / $height; } elseif ($width==$height){ $retWidth = $thumbFactor; $retHeight = $thumbFactor ; } else die ("unknown scenario"); $outStr = $retWidth.",".$retHeight; // $outStr = "115,115"; Link to comment https://forums.phpfreaks.com/topic/65538-problem-with-thumb-images/ Share on other sites More sharing options...
Fadion Posted August 18, 2007 Share Posted August 18, 2007 U're creating thumbs with GD i guess, as from what i quickly saw, your code only calculates the image dimensions. If so post that code, otherwise ive no idea. Link to comment https://forums.phpfreaks.com/topic/65538-problem-with-thumb-images/#findComment-327247 Share on other sites More sharing options...
tibberous Posted August 18, 2007 Share Posted August 18, 2007 I might be able to round up some thumbnail code for you, but unless your site gets like 10 visitors a month, you want to cache thumbnails. Just after you make the image, store it in a folder, and then pull from the folder. Link to comment https://forums.phpfreaks.com/topic/65538-problem-with-thumb-images/#findComment-327258 Share on other sites More sharing options...
jonw118 Posted August 18, 2007 Author Share Posted August 18, 2007 Thanks for the help! This is where I have no idea what I'm doing... this is a site we had custom programmed. I know just enough PHP to be dangerous when it comes to this. This is something my developers never really addresses/fixed - the grainy images. Link to comment https://forums.phpfreaks.com/topic/65538-problem-with-thumb-images/#findComment-327261 Share on other sites More sharing options...
TheFilmGod Posted August 18, 2007 Share Posted August 18, 2007 case 2://Prev $cStr = "pr_"; nreak; nreak needs to be "break" Link to comment https://forums.phpfreaks.com/topic/65538-problem-with-thumb-images/#findComment-327263 Share on other sites More sharing options...
Fadion Posted August 18, 2007 Share Posted August 18, 2007 Still there is no explanation to this but anyway im giving my 2 cents. Usually u get grainy images when using a fixed width & height img tag and placing into it an image with different size, or with GD when using imagecopyresized() instead of imagecopyresampled(). Again i think the code u provided doesnt have to do with grainy images, only if u misscalculated image proportions which still dont think is the case. Link to comment https://forums.phpfreaks.com/topic/65538-problem-with-thumb-images/#findComment-327272 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.