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

    I have GD 2 now but I remember when it was 1.x, the quality (no matter what i did was always much less than when using photoshop, etc).

    GD 2 file quality is much closer to photoshop now and file sizes seem to (for the most part) match. As you noted though, GD 2 doesn't allow GIF.

    Let me ask you this... Have you tried converting your images to any other format? Try Jpeg or PNG and see if the sizes/quality are any better.

    The only other thing I can suggest is upgrade GD and just use Jpeg. (Why convert a jpeg to a gif anyway?)

      Thanks for the advice.

      Unfortunately, the image must be exported as GIF. They are for use on mobile phones and GIF is the only image format supported by all handsets.

      The reason the original is a JPEG is because many of them are taken from photographs. Despite this factor, using Photoshop the jpegs are reproduced to a high quality in the GIF format.

      Having posted on several forums, it appears that the reason is that Photoshop and later versions of GD resample images whereas I am currently producing a hard resized version.

      Thanks again,
      Paul

        You might also try ImageMagick. I believe you can enable GIF manipulation in it.

          Write a Reply...