Linking information theory and thermodynamics to spatial resolution in photothermal and photoacoustic imaging