Why my thumbnails doesn't look same as orginal picture? Colors are wrong, but I don't know how I fix them. Here is code: PHP: <?php $image_path = "images/"; //Kansio jossa alkuperäiset kuvat on $thumb_path = "thumbs/"; //Kansio johon Thumbnail kuvat laitetaan $thumb_width = 100; //Thumbin leveys //Avataan Kansio jossa kuvat ovat $hak = opendir($image_path); //luetaan ensimmäisen tiedoston nimi $image_name = readdir($hak); //jatketaan niin kauan kun $nimi ei ole false while ($image_name) { //tulostetaan tiedoston nimi thumbnail($image_path,$thumb_path,$image_name,$thumb_width); //luetaan seuraavan tiedoston nimi $image_name = readdir($hak); } //suljetaan hakemisto closedir($hak); function thumbnail($image_path,$thumb_path,$image_name,$thumb_width) { $orginal_path = $image_path .'/'.$image_name; $src_img = imagecreatefromjpeg($orginal_path); $origw=imagesx($src_img); $origh=imagesy($src_img); $new_w = $thumb_width; $diff=$origw/$new_w; $new_h=$new_w; $dst_img = imagecreate($new_w,$new_h); imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img)); $destination_path = $thumb_path .'/'.$image_name; imagejpeg($dst_img, $destination_path); return true; echo 'Kuva ' . $image_name . ' on muutettu thumbnailiksi onnistuneesti'; } ?>
Now I have bigger problem now it only show Warnings: Warning: imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error: in /mbnet/v/veskue/imagegallery/creator.php on line 23 Warning: imagecreatefromjpeg(): 'images//.' is not a valid JPEG file in /mbnet/v/veskue/imagegallery/creator.php on line 23 Warning: imagesx(): supplied argument is not a valid Image resource in /mbnet/v/veskue/imagegallery/creator.php on line 24 Warning: imagesy(): supplied argument is not a valid Image resource in /mbnet/v/veskue/imagegallery/creator.php on line 25 Warning: imagesx(): supplied argument is not a valid Image resource in /mbnet/v/veskue/imagegallery/creator.php on line 30 Warning: imagesy(): supplied argument is not a valid Image resource in /mbnet/v/veskue/imagegallery/creator.php on line 30 Warning: imagecopyresized(): supplied argument is not a valid Image resource in /mbnet/v/veskue/imagegallery/creator.php on line 30 Warning: imagejpeg(): Unable to open 'thumbs//.' for writing in /mbnet/v/veskue/imagegallery/creator.php on line 33 Warning: imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error: in /mbnet/v/veskue/imagegallery/creator.php on line 23 Warning: imagecreatefromjpeg(): 'images//..' is not a valid JPEG file in /mbnet/v/veskue/imagegallery/creator.php on line 23 Warning: imagesx(): supplied argument is not a valid Image resource in /mbnet/v/veskue/imagegallery/creator.php on line 24 Warning: imagesy(): supplied argument is not a valid Image resource in /mbnet/v/veskue/imagegallery/creator.php on line 25 Warning: imagesx(): supplied argument is not a valid Image resource in /mbnet/v/veskue/imagegallery/creator.php on line 30 Warning: imagesy(): supplied argument is not a valid Image resource in /mbnet/v/veskue/imagegallery/creator.php on line 30 Warning: imagecopyresized(): supplied argument is not a valid Image resource in /mbnet/v/veskue/imagegallery/creator.php on line 30 Warning: imagejpeg(): Unable to open 'thumbs//..' for writing in /mbnet/v/veskue/imagegallery/creator.php on line 33 What is wrong
Try using a different image! If that doesn't work try undoing the last change you made to the code! imagecreatetruecolor() requires GD 2.0.1 or later.