list($width, $height, $type, $attr) = getimagesize($yourImage); if($width =< 500) { //too small } else { //resize your image }