Jump to content
php.lv forumi

problēma ar bildēm


J-EX

Recommended Posts

Tātad esmu uzrakstījis skriptu, kas samazina bildes. Vis darbojas lieliski, bet bilžu kvalitāte acīmredzami klibo... :(

 

lai izveidotu bildes failu izmantoju funkciju: imagejpeg() .... quality norādu uz 100...

 

bet bildes sanāk tādas "robainas", itkā būtu slikts krāsu kontrasts... Vai kāds var ieteikt kautko?

Paldies...

Link to comment
Share on other sites

//saglabaajam bildes
if (($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg")
&& ($_FILES["file"]["size"] < 2000000))
 {
 if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
 else
{
// ielaadeetaa faila satura ieguana
  $pic1 = ImageCreateFromJpeg($_FILES["file"]["tmp_name"]);
  $h=ImageSY($pic1);
  $w=ImageSX($pic1);
// bil˛u izmeru konstantes
  $min = 130;
  $max = 300;
// kvalitaates konstante
  $q = 100;			
  $location = getcwd()."/small/".$bfile;
  $locationmax = getcwd()."/large/".$bfile;

// ----- veidojam mazo bildi	

if($h>$w){	$h1 = $min;
		  $w1 = floor($h1/$h*$w);
	 	  $thumb = imagecreatetruecolor($w1, $h1);
		  imagecopyresized($thumb, $pic1, 0, 0, 0, 0, $w1, $h1, $w, $h);
		  imagejpeg($thumb,$location,$q);
}

// un taa talaak... bildes tiek saglabaatas peec proporcijaam...

 

tas ir fragments no koda

Edited by J-EX
Link to comment
Share on other sites

×
×
  • Create New...