The N-H bond of an imide is especially acidic because the resulting anion is resonance stabilized by the two flanking carbonyl
groups.
Note ↑: The carbonyl carbon of an amide is sp2
hybridized and has trigonal planar geometry. A second
resonance structure can be drawn that delocalizes the nonbonded electron pair on the N atom.
Amides are more resonance stabilized than other acyl compounds, so the resonance structure
having the C=N makes a significant contribution to the hybrid.