SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Feb 2004
    Location
    Worcs, UK
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry Resizing Gifs - filesize any quality issues

    Alright ppl,

    I'm tearing my hair out on this one...

    I'm currently resizing a batch of JPEG's (approx 100,000 @ 1024x768) down to GIF's (thumbnails). My hosting company currently has GD library 1.62 installed and I am able to convert between JPEG and GIF ok.

    The problem is that the original Jpegs are around 20k-30k. If I use Fireworks, Photoshop etc and manually convert them the quality is great and they are around 1k. Using the function included below the quality is nowhere near as good and the average size is around 6k - a huge increase when you consider that this applies to 100,000 images.

    function sizeImage($src, $dest, $w, $h) {
    $attr = getimagesize($src);
    $img_src = imagecreatefromjpeg($src);
    $img_dest = imagecreate($w,$h);
    imagecopyresized($img_dest, $img_src, 0, 0, 0, 0, $w, $h, $attr[0], $attr[1]);
    imagegif($img_dest);//, $dest);
    imagedestroy($img_dst);
    }

    Any help would be greatly appreciated.

    Cheers,
    Paul

  2. #2

    Join Date
    Oct 2003
    Location
    €uroLand
    Posts
    1,340
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would use imagecopyresampled and make the thumbnails jpegs too.

  3. #3
    SitePoint Member
    Join Date
    Feb 2004
    Location
    Worcs, UK
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    imagecopyresampled

    Quote Originally Posted by drzoid
    I would use imagecopyresampled and make the thumbnails jpegs too.
    Hi drzoid,

    Thanks for the advice. Unfortunately, the work is for a client and the thumbnails need to remain as GIF's. Also, the hosting company used doesn't support GD 2.0.l or greater. As a result I am unable to implement any truecolor image functionailty or resampling.

    I have use GD 2+ on my own websites and it really makes a difference with regard resampling and PNG/JPG's.

    Cheers,
    Paul

  4. #4

    Join Date
    Oct 2003
    Location
    €uroLand
    Posts
    1,340
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did your manual test actually produce nice 256 colors thumbnails? The problem is that these application usually resample images while imagecopyresized only does a "hard" resizing.

  5. #5
    SitePoint Evangelist Daijoubu's Avatar
    Join Date
    Oct 2002
    Location
    Canada QC
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep, pixel resizing...
    PNG 256 colors is best for thumbs (small one)
    Generaly smaller in size compared to gif

    And since GIF writing support have been removed in the newer versions of PHP (GD2?), can't go wrong using PNG...
    Or perhaps take a look at imagick
    Speed & scalability in mind...
    If you find my reply helpful, fell free to give me a point

  6. #6
    SitePoint Member
    Join Date
    Feb 2004
    Location
    Worcs, UK
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cheers

    Thanks for all your help.

    Looks like I'm going to try and get either ImageMagick installed on the hosting server or GD version 2.0.1. Just need to persuade the hosting company - wish me luck!

    Laters
    Paul


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •