How to measure for gate

Measurements needed for gates

How to measure for a new gate

What to measure to work out what size gate I need.