Morsusy2k Posted October 11, 2013 Share Posted October 11, 2013 Hi, I am having trouble with creating thumbnails of the pictures uploaded on my website. This script on the first sight works perfectly but when I opened some of the files,some were ok but some lost too much of their color and become almost white,some almost black,others lost quality (on some you can't even say what is on them)..etc.. function thumbnail($image_path,$thumb_path,$image_name,$thumb_width) { $src_img = imagecreatefromjpeg("$image_path/$image_name"); $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)); imagejpeg($dst_img, "$thumb_path/$image_name"); RETURN TRUE; } Is there any way to do this in function like this but better working? Thanks. Link to comment Share on other sites More sharing options...
davej Posted October 11, 2013 Share Posted October 11, 2013 http://php.net/manual/en/function.imagecreate.php ...recommends... http://www.php.net/manual/en/function.imagecreatetruecolor.php Link to comment Share on other sites More sharing options...
justsomeguy Posted October 11, 2013 Share Posted October 11, 2013 I would also use imagecopyresampled instead of imagecopyresized. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now