Detect image orientation