raise an error for invalid image size