If you've ever looked at a picture on the Internet, there is a very good chance it was a .jpg file. (Pronounced jay-peg.)
JPEG is a means of compressing digital image files so that the representation of the picture uses fewer megabytes. So it's not about changing the number of pixels - which determines the physical dimensions, but rather the amount of information stored against each pixel in order to reduce the file size. This is important because smaller files are able to be transmitted faster over the internet. Waiting for a webpage to load the images is a painful experience.
The creator of the JPEG is able to dial in the amount of compression to make the file smaller if he/she wants. And smaller is better, isn't it? Not really. There is an optimum. The more we compress our picture, the more data we are leaving out, and the more blocky and yucky the resulting image looks.
You've seen the image above previously. Compare the top to the bottom - look closely at the wall on the left and the ground on the right. The compression makes it blotchy and indistinct. Incidentally, the file size with no compression is 600KB, and will full compression it is 78KB.
"JPEG" stands for Joint Photographic Experts Group, the name of the committee that created the JPEG standard. You can read more about it on wikipedia if you're interested. https://en.wikipedia.org/wiki/JPEG
You'll hear photographers say things like "I shoot RAW!" That means they have set their camera to save the photo files without any compression or effects applied. This is important because it gives us the maximum amount of data in the image file to work with. To equate it to film photography, these are digital negatives. Dive into the details on wikipedia: https://en.wikipedia.org/wiki/Raw_image_format
RAW is the file format that preserves all the data exactly as the camera's sensor recorded it. Warts and all. In fact, when you look at a RAW image, it may seem a bit flat and possibly even not as sharp as you'd expect. You're expected to run the RAW file through some form of post processing to spruce it up and then save it out as a JPEG to be used elsewhere.
There is a parallel in audio recording. Remember those mix tapes you recorded off the radio? Compare the crackly, wobbly audio quality to the master recording done in studio.
Every different camera manufacturer has a different file format for their RAW files. And in fact different cameras may have their own subformats too. (This is relevant if you buy the absolute latest camera, you may have to update your software like Lightroom too.) Canon RAW files are identified with the extension .CR2. Nikon cameras produce .NEF files.
Perhaps the most significant difference and advantage of RAW over JPEG is the bit depth, or amount of data stored for each pixel. For JPEG, the maximum is about 8-bits, or about 256 shades of a colour. (Imagine a red pixel, ranging in tone from black to dark red, to mid-red, to bright red.)
Cameras are able to capture images, and save RAW files with 14-bits per pixel, or 16384 shades. (Imagine same red pixel, but this time there aren't just 256 steps, and the result is a much smoother, barely perceptible graduation in the tones from black to full red.
For us photographers, we want to record as much information as possible to allow us ample opportunity to tweak and manipulate the image. So where are those other 16000 shades of red that are supposedly stored in a RAW file? They will be most evident in the very dark and very bright part of your image.
If you get the exposure wrong, and you're shooting JPEG, there's not much you can do. But if you're shooting RAW, obviously within limits, you can still get back quite a bit of the data that may otherwise seem lost.
(You'll probably also remember the giraffe image from the after-the-shot post.)
With JPEG, the colour balance is baked into the file, so in post processing, while you can change the hue of the overall image, it's not the same as having a RAW file were you can apply an accurate white balance. See the Rainbows post.
There are a couple of downsides to shooting RAW though.
RAW files tend to be quite large, relatively, because they are storing more data in an uncompressed format. From what I've noticed, as a very rough guide, RAW files from a 10 megapixel camera will be about 10-to-12 megabytes on disk. I just did a quick test with my 18 megapixel Canon 7D. I took a picture of the curtains and the RAW file is 26MB, but when I shot the same image in JPEG, it was 5.5MB. (The exact size of each file can vary by a number of factors which we won't go into here.)
So if I have a 4GB memory card in the camera, and shooting RAW, I could take about 153 photos. But if I was shooting JPEG, I could fit over 700 photos on the card.
RAW files are not meant to be "publicly" displayed - they need to be post processed in some way, and converted to JPEG, or other format, for use on the Twitbooks, or printed, or even made into a background for your computer's desktop. These are the digital negatives remember, so they need to be "developed". This adds an extra step into the process of using the images.
In practice, I recommend shooting RAW. Memory cards and computer disks are cheap, and we are nine-times-out-of-ten going to edit / develop / post process our images anyway. The benefits of having more data to work with, and being able to tweak exposure and colour balance certainly makes shooting in RAW a no-brainer.
But we still have to convert the images we want to JPEG so they can be displayed elsewhere. As a general, vague guide, you will want to scale the images down to a smaller size - for use on the internet somewhere around 800 to 1200 pixels across should be fine. And you can set the compression to about 80% to achieve a much smaller file size, with hardly any perceptible loss of quality.
Lastly, if you intend to print an image you should use the file with the largest number of pixels and least compression.