A search for the resonant production of high-mass photon pairs is presented. The search focuses on spin-0 and spin-2 resonances with masses between 0.5 and 4.5 TeV, and with widths, relative to the mass, between 1.4×10−41.4×10−4 and 5.6×10−25.6×10−2. The data sample corresponds to an integrated luminosity of 12.9 fb−112.9 fb−1 of proton–proton collisions collected with the CMS detector in 2016 at a center-of-mass energy of 13 TeV. No significant excess is observed relative to the standard model expectation. The results of the search are combined statistically with those previously obtained in 2012 and 2015 at View the MathML sources=8 and 13 TeV, respectively, corresponding to integrated luminosities of 19.7 and 3.3 fb−13.3 fb−1, to derive exclusion limits on scalar resonances produced through gluon–gluon fusion, and on Randall–Sundrum gravitons. The lower mass limits for Randall–Sundrum gravitons range from 1.95 to 4.45 TeV for coupling parameters between 0.01 and 0.2. These are the most stringent limits on Randall–Sundrum graviton production to date.