Within some linear range, the intensity of stained DNA bands in a gel is directly proportional to their mass. By making a standard curve from bands of known mass, the mass of unknown bands can be estimated. This process is called densitometry. I wrote briefly about its use in quantifying protein bands after SDS-PAGE in this answer, but I'll go into more detail on how this is done using the following ethidium bromide stained gel:

On the right is a molecular weight marker (BstEII digest of λ DNA) with bands of known mass. On the left are two bands of unknown mass (actually a double-cut plasmid).
I use a free program called ImageJ to estimate band intensities. They have a tutorial on measuring band intensity here. You can also get ImageJ packaged with Java (and bunch of other stuff) in the software Fiji.
Open the image in ImageJ and use the Rectangle
tool to draw a box around the marker, then select Analyze > Gels > Select First Lane
(or shortcut Ctrl+1
). Next, drag the box over to surround the other lane and select Analyze > Gels > Select Next Lane
(Ctrl+2
). Now select Analyze > Gels > Plot Lanes
(Ctrl+3
) to plot image intensity as a function of position on the gel:

The area under each peak (minus the background noise) represents the some total of intensity for each band. To measure this area, use the line (Straight
) tool to draw bounds on the base of each peak:

I've done it somewhat haphazardly here, but you get the idea. Now, using the wand tool, click inside each peak and ImageJ will tabulate the integrated intensity of each. Shown below are the intensities of the marker bands (with the top band being Band 1) as well as their masses (which are known):
Mass (ng) Intensity
Band 1 45 5319.891
Band 2 28 3816.234
Band 3 24 3256.406
Band 4 16 2298.749
Band 5 15 2074.749
Band 6 8 1084.991
Take this data into Excel (or similar) and plot intensity as a function of mass. Band 1 looks like it is outside the linear range and is underestimating the mass. This was actually expected since, if you look closely at the band in the gel image, there are red pixels indicating that it is oversaturated. Ignore this band and perform a linear regression on the rest.

The regression gives the equation $I = 134.74M + 53.988$ with $R^2 = 0.9975$. Rearranging for mass, we have $M = \frac{I - 53.988}{134.74}$. Get the intensity of the unknown bands as described above and calculate their mass with the preceding equation:
Mass (ng) Intensity
Band 1 27 3736.991
Band 2 15 2125.284