Him being denied a goalscoring opportunity decides the card, not whether it's a penalty or not.
If being denied a goalscoring opportunity had any bearing on whether a foul happened there would literally never be any freekicks given 10 yards outside the box and beyond.