A solution to the linear wave conversion problem in weakly inhomogeneous plasmas