$image_url = '/myimage.jpg'; $max_size = 500px; list($width, $height, $t, $i) = getimagesize($image_url); if($width > $max_size || $height > $max_size) { // use image lib }