It was recently proposed that the $X(3872)$ binding energy, the difference between the $D^0bar D^{*0}$ threshold and the $X(3872)$ mass, can be precisely determined by measuring the $gamma X(3872)$ line shape from a short-distance $D^{*0}bar D^{*0}$ source produced at high-energy experiments. Here, we investigate the feasibility of such a proposal by estimating the cross sections for the $e^+e^-topi^0gamma X(3872)$ and $pbar ptogamma X(3872)$ processes considering the $D^{*0}bar D^{*0}D^0/bar D^{*0}D^{*0}bar D^0$ triangle loops. These loops can produce a triangle singularity slightly above the $D^{*0}bar D^{*0}$ threshold. It is found that the peak structures originating from the $D^{*0}bar D^{*0}$ threshold cusp and the triangle singularity are not altered much by the energy dependence introduced by the $e^+e^-topi^0D^{*0}bar D^{*0}$ and $pbar ptobar D^{*0}D^{*0}$ production parts or by considering a finite width for the $X(3872)$. We find that $sigma(e^+e^-topi^0gamma X(3872)) times {rm Br}(X(3872)topi^+pi^-J/psi)$ is $mathcal{O}(0.1~{rm fb})$ with the $gamma X(3872)$ invariant mass integrated from 4.01 to 4.02 GeV and the c.m. energy of the $e^+e^-$ pair fixed at 4.23 GeV. The cross section $sigma(pbar ptogamma X(3872))times {rm Br}(X(3872)topi^+pi^-J/psi)$ is estimated to be of $mathcal{O}(10~{rm pb})$. Our results suggest that a precise measurement of the $X(3872)$ binding energy can be done at PANDA.