Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.