You're confusing resolution with quality. JPEG is a lossy compression format, and you can adjust how lossy it is. That's the quality, and has nothing to do with its dpi resolution. Assuming you haven't been manipulating the image (which is unlikely, otherwise why would you be using GD Lib?🙂) then every pixel in the original image is in the output image; changing the dpi setting won't change that, and fiddling with the image quality won't change the dpi or the image's dimensions.
GD Lib does reset the dpi to a default value (it does not retain such metadata in its internal image representation); but the appropriate dpi value is dependent on the output device, and GD assumes the result will be rendered on a screen.
However, poking around php.net's documentation, I find this, which may be useful to you.