PDA

View Full Version : image resize


fractalvibes
11-06-2002, 03:18 AM
Hi,

I am trying to do some image resizing with images uploaded to
a gallery in order to create thumbnails to display. The quality of the thumbnails seems to be very lacking - washed-out, blurry, whited-out is often the result. Does anyone have any ideas as to how the quality might be improved, or I am totally at the mercy of the PHP function used? Code below - any and all ideas quite welcome.

thanks,

Phil J.

-------- code follows ------------------
$size = GetImageSize($image);
$width = $size[0];
$height = $size[1];

// make it 1/4 the size
$tnwidth = $width / 4;
$tnheight = $height / 4;

// fetch the original
$src = ImageCreateFromjpeg($image);

// create a container for new image
$dest = ImageCreate($tnwidth,$tnheight);

// make the resized copy
ImageCopyResized($dest,$src,0,0,0,0,$tnwidth,$tnheight,$width, $height);

Ökii
11-06-2002, 12:55 PM
ImageCreate(width,height) sadly only has functionality with a reduced palette.
Due to being restricted to 256 colours, your output will look shoddy (gif-like).

Luckily (w00t w00t) there is a sneaky workaround that I discovered a month or so back.

For full details, read this tutorial (http://fitale.com/devsys/index.php?secta=tutorials&subsect=increased_palette) for more info.

Subnote: If you have GD2 or above, simply change to using ImageCreateTrueColor(width,height) and ImageCopyResampled()