While we can't vouch for it as we haven't tried it, there's a utility called Tiny Umbrella (for Mac and Windows) which claims to get your iDevice out of recovery mode without erasing any data, so you shouldn't lose any photos, videos, contacts and so on. Other applications are available, such as RecBoot for Mac OS.
When you run these utilities, they offer an option to enter or exit recovery mode - it's a simple case of clicking the button with your iPhone or iPad already connected to your PC via a USB cable.
Another trick to try, if you have a jailbroken device and are having problems, is to power off the device as in step 2 below. Then turn it on by holding the power button and the volume up button. As soon as the screen lights up (and before the Apple logo appears) release the power button but continue holding the volume up button. This turns off add-ons and tweaks and - hopefully - should allow your iPhone or iPad to boot without the mods running and - crucially - without losing any data.
If you have a recent backup of your non-jailbroken device, follow these steps:
Putting your iPhone or iPad into recovery mode
(if your device is already in recovery mode, scroll down to step 7)
NOTE: Recovery mode is not DFU mode. Recovery mode is where your iOS device loads iBoot, a bootloader which allows your iPhone or iPad to be restored using the existing or newest firmware. DFU mode bypasses the standard restoring procedures and lets you do more advanced things like downgrading the firmware - we won't cover this here.
Make sure your device is unplugged from your computer (this should be the computer that you use to sync your iPhone / iPad). You can leave the USB cable connected to your PC or Mac, though.
Turn off your iPhone / iPad. Press and hold the power button on the top edge until a slider appears. Slide it to power off your device. If the slider doesn't appear (because your iOS device has frozen up) then hold the power and Home buttons down until the iPhone or iPad turns off.