मैं निम्नलिखित समारोहछवि PHP में इस मुद्दे का आकार परिवर्तन - जीडी बदसूरत आकृति परिवर्तन छवियों
/*creates thumbnail of required dimensions*/
function createThumbnailofSize($sourcefilepath,$destdir,$reqwidth,$reqheight,$aspectratio=false)
{
/*
* $sourcefilepath = absolute source file path of jpeg
* $destdir = absolute path of destination directory of thumbnail ending with "/"
*/
$thumbWidth = $reqwidth; /*pixels*/
$filename = split("[/\\]",$sourcefilepath);
$filename = $filename[count($filename)-1];
$thumbnail_path = $destdir.$filename;
$image_file = $sourcefilepath;
$img = imagecreatefromjpeg($image_file);
$width = imagesx($img);
$height = imagesy($img);
// calculate thumbnail size
$new_width = $thumbWidth;
if($aspectratio==true)
{
$new_height = floor($height * ($thumbWidth/$width));
}
else
{
$new_height = $reqheight;
}
// create a new temporary image
$tmp_img = imagecreatetruecolor($new_width, $new_height);
// copy and resize old image into new image
imagecopyresized($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
// save thumbnail into a file
$returnvalue = imagejpeg($tmp_img,$thumbnail_path);
imagedestroy($img);
return $returnvalue;
}
उपयोग करते हुए मेरे PHP स्क्रिप्ट से तय ऊंचाई और चौड़ाई के थंबनेल बनाने हूँ बनाता है और मैं निम्नलिखित मानकों
createThumbnailofSize($sourcefilepath,$destdir,48,48,false);
के साथ इस समारोह फोन
लेकिन समस्या यह है कि परिणामस्वरूप छवि बहुत खराब गुणवत्ता का है, जब मैं एडोब फोटो शॉप के साथ एक ही ऑपरेशन करता हूं, तो यह एक अच्छा रूपांतरण करता है .. ऐसा क्यों है? मैं किसी भी गुणवत्ता पैरामीटर को खोजने में असमर्थ हूं, जिसके माध्यम से मैं आउटपुट छवि की गुणवत्ता बदलता हूं ..
imagecopyresampled() द्वि-घन आकार बदलने एल्गोरिथ्म – Jacco
धन्यवाद एक बहुत का उपयोग करता है, मुझे यह कार्य करने के लिए प्रयास करें –
अन्य महत्वपूर्ण बिंदु हैं: कुछ थंबनेल पूरी तरह से काले हैं। यह मुद्दा कुछ कैमरों और सेलफोन से आ सकता है जो कुछ अतिरिक्त पात्र जोड़ते हैं। इस समस्या से बचने के लिए, इसे जोड़ें: 'ini_set (" gd.jpeg_ignore_warning ", 1);'। फिर आपको केवल यह चेतावनी मिलेगी 'भ्रष्ट जेपीईजी डेटा: मार्कर 0xd9' से पहले 2 बाहरी बाइट्स लेकिन थंबनेल सही ढंग से जेनरेट किया जाएगा। – Toto