$h = imagesy($old)); // calculate fill fit if($w > $h) list($nw,$nh) = lol_magic_scale($w,$h, -1,200); else list($nw,$nh) = lol_magic_scale($w,$h, 200,-1); // scale it down. $new = imagecreatetruecolor($nw,$nh); imagecopyresampled( $new, $old, 0,0 ,0,0, $nw,$nh, $w,$h ); imagedestroy($old); unset($old); // crop off the excess from either end to center it and fit it $last = imagecreatetruecolor(200,200); imagecopyresampled( $last, $new, 0, 0, ($nw / 2) – (200 / 2), ($nh / 2) – (200 / 2), 200, 200, 200, 200 ); // if i fits i sits. imagepng($last,$filename); imagedestroy($new); imagedestroy($last);