Page 1 of 1

crap quality

Posted: Tue Oct 25, 2005 9:45 am
by shiznatix
this thumbnail script is turning out images that seam to be missing bright colors. everything is dark and crappy even though i made imagejpeg at the highest quality

Code: Select all

function createThumb($image_path,$thumb_path,$image_name,$thumb_width = 100)
    {
        $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", 70);
        return true;
    }
what am i missing here?

Posted: Tue Oct 25, 2005 9:50 am
by n00b Saibot
two thing jump out at me :arrow:

Code: Select all

imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img));
and

Code: Select all

imagejpeg($dst_img, "$thumb_path/$image_name", 70);
first should be imagecopyresampled() and in second change 70 to 100.

Posted: Tue Oct 25, 2005 9:50 am
by John Cartwright
http://ca.php.net/imagecreate wrote:Description
resource imagecreate ( int x_size, int y_size )

imagecreate() returns an image identifier representing a blank image of size x_size by y_size.

We recommend the use of imagecreatetruecolor().
:wink:

Posted: Tue Oct 25, 2005 2:08 pm
by onion2k
n00b Saibot wrote:first should be imagecopyresampled() and in second change 70 to 100.
There's pretty much never a reason to use a quality value of 100 on a jpeg. The difference between 80 and 100 is virtually impossible to detect. As it is, the quality value only affects the quantisation .. essentially it means "discard the least common values" where 'least common' is determined by the quality .. it does nothing to actually change the values of the colours. Depending on the jpeg library the quality value may also affect the chroma subsample value .. but that's not very interesting.

Posted: Tue Oct 25, 2005 3:25 pm
by shiznatix
man you guys roxorz. imagecreatetruecolor worked like ultra good amazing. beers all around

Posted: Wed Oct 26, 2005 4:52 am
by n00b Saibot
onion2k wrote:Depending on the jpeg library the quality value may also affect the chroma subsample value .. but that's not very interesting.
yeah! it looks so :? :lol:
shiznatix wrote:beers all around
no thanks, i will take Mt. Dew :D