you can use
$fileSize = getimagesize("filename.jpg");
which will return a value similar to
width="625" height="233"
so i would say, if you are using exact sizes, then yes, get your variable like this, then do the following
if($fileSize[3] == "width=\"300\" height=\"400\") {
do this
} else {
do that
}
edit: corrected syntax,(thanks bradgrafelmanfor pointing it out) will return the values i supplied, tested and works now