Jump to content

Problem with thumb images


jonw118

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.