Pull the pins out of the door hinges, remove the door and set it aside.
Pry off the casing from both sides of the door opening, using a pry bar. Work carefully, starting at the bottom of the vertical pieces and moving toward the top. Finish with the trim covering the jamb header. Tap out the nails with a hammer, or cut them flush to the inside of the trim with wire snippers.
Fit a reciprocating saw with a metal-cutting blade, work the blade between the knob-side jamb and the framing and cut through the nails that hold the jamb to the framing. Remove the jamb when you're done, and then repeat the procedure with the hinge-side jamb and remove it as well. Discard all the shims that fall out when you remove the jambs.
Place a 2-foot level flat against the surface of the header jamb, and gently pry down one side or the other until the bubble is centered. Tap a pair of cedar shims into the space you created, inserting one shim from one side of the jamb and one from the other so they meet behind the jamb.
Pound a 2-inch finish nail partially into the jamb at the point where the shims intersect, approximately 1 inch from one side of the jamb. Check the level again, and if the bubble is still centered, pound the nail in the rest of the way and sink the head with a nail punch. Drive another nail into the jamb at the same place, but an inch from the other side of the jamb, and sink it as well.
Place the knob-side jamb back in position against the framing after first cutting an appropriate length off the bottom with a circular saw if you had to lower the end of the header jamb. Plumb the jamb with the level, and then insert pairs of shims behind it at 12-inch intervals and partially drive pairs of 2-inch nails through the jamb and the shims and into the framing.
Check the level again, and if the bubble is centered, drive the nails all the way and sink the heads with a nail punch. When you're done, repeat the procedure with the hinge-side jamb.
Nail the casing back in place, using 1-1/2-inch finishing nails, and sink the nail heads with a nail punch. Fill all the nail holes in the jamb and casing, and repaint the jamb. Rehang the door after the paint dries.