hmm... jpeg convertion quality was bad!!!
Posted: Wed Jun 02, 2004 6:42 am
recently, i hv reference a turtorial of learning making thumbnail...
yeah~ it is work... but the color of the picture was lost... (grey-scale?!)...
The following is the picture i convert...

and the following is what i've converted..

hmm... i wonder how can i enhance the "quality"... i new with GD library...
the following is the code i learn...
the script... the code must place in the same folder with the picture, and u need to create a mysql table named "images" and a column name "image_path" (as shown in the code)... and the table should insert the name of the jpg picture...
hmm.. can anyone give me the way to enhance the quality?
tq....

yeah~ it is work... but the color of the picture was lost... (grey-scale?!)...
The following is the picture i convert...

and the following is what i've converted..

hmm... i wonder how can i enhance the "quality"... i new with GD library...
the following is the code i learn...
Code: Select all
<?
header("Content-type: image/jpeg");
$new_width=100; //Image width Change if needed
$new_height=200; //Image height Change if needed
$source_path=""; //Source File path
$destination_path="thumb/"; //Destination file path
$db = mysql_connect("localhost", "root") or die("Cannot Connect"); // Database Connection
mysql_select_db("test",$db) or die("Cannot open database"); //Database Name
$sql = mysql_query("SELECT * FROM images") or die("Query failed"); //Query
while ($row = mysql_fetch_array($sql))
{
echo "$rowї0]<BR>";
$image_name = $rowї0]; //Image path retrived
//Identifying Image type
$len = strlen($image_name);
$pos =strpos($image_name,".");
$type = substr($image_name,$pos + 1,$len);
if ( $type=="jpeg" || $type=="jpg")
{
thumb_jpeg ($image_name); //Call to jpeg function
}
echo "<b>Done........</b>";
}
//JPEG function
function thumb_jpeg($image_name)
{
global $source_path;
global $destination_path;
global $new_width;
global $new_height;
$destimg=ImageCreate($new_width,$new_height) or die("Problem In Creating image");
$srcimg=ImageCreateFromJPEG($source_path.$image_name) or die("Problem In opening Source Image");
ImageCopyResized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die("Problem In resizing");
ImageJPEG($destimg,$destination_path.$image_name,100) or die("Problem In saving");
}
?>hmm.. can anyone give me the way to enhance the quality?
tq....