crap quality

Need help with Photoshop, the GIMP, Illustrator, or others? Want to show off your work? Looking for advice on your newest Flash stuff?

Moderator: General Moderators

Post Reply
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

crap quality

Post 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?
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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:
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

man you guys roxorz. imagecreatetruecolor worked like ultra good amazing. beers all around
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post 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
Post Reply