switch if order to mask the slow image dimension reading