For Photoshop it is done this way (check step 10):
http://abduzeedo.com/perspective-without-the-vanish-point-filter