0) { $percent = $percent * 0.01; $w = $sw * $percent; $h = $sh * $percent; } else { if (isset ($w) AND !isset ($h)) { $h = (100 / ($sw / $w)) * .01; $h = @round ($sh * $h); } elseif (isset ($h) AND !isset ($w)) { $w = (100 / ($sh / $h)) * .01; $w = @round ($sw * $w); } elseif (isset ($h) AND isset ($w) AND isset ($constrain)) { $hx = (100 / ($sw / $w)) * .01; $hx = @round ($sh * $hx); $wx = (100 / ($sh / $h)) * .01; $wx = @round ($sw * $wx); if ($hx < $h) { $h = (100 / ($sw / $w)) * .01; $h = @round ($sh * $h); } else { $w = (100 / ($sh / $h)) * .01; $w = @round ($sw * $w); } } } $im = @ImageCreateFromJPEG ($img) or $im = @ImageCreateFromGIF ($img) or $im = false; if (!$im) { readfile ($img); } else { $thumb = @ImageCreateTrueColor ($w, $h); @ImageCopyResampled ($thumb, $im, 0, 0, 0, 0, $w, $h, $sw, $sh); @ImageJPEG ($thumb); } ?>