Compression of phase-switched optical pulses in a resonant absorber