function scale_image ($image, $width, $height, $percent
{
$ewidth = imagesx$image);
$eheight = imagesy$image);
if ($percent) {
$width = round(($width/100)*$ewidth);
$height = round(($height/100)*$eheight);
}
$image2 = image_create_alpha$width, $height);
for ($x=0;$x$width$x++) {
$x1 = floor$x * ($ewidth$width));
for ($y=0;$y$height$y++) {
$y1 = floor$y * ($eheight$height));
$index = imagecolorat$image, $x1, $y1);
$color = imagecolorsforindex$image, $index);
$trans = imagecolorallocatealpha$image2
$color'red'],
$color'green'],
$color'blue'],
$color'alpha']);
imagesetpixel$image2, $x, $y, $trans);
}
}
return $image2
}