daltman1967,
Its highly doubtful you can use JavaScript for this type of manipulation.
You can use PHP with ImageMagick -- assuming it is installed. From what I've read from a quick google search is that it must be done through exec() or system().
This is a quote from an older post:
mogrify -density 300 filename.jpg
You can also try modifying the suggestion from the PHP manual here.
Please be very aware that automated conversion of image density (changing the DPI) may not result in a perfect quality image.
From my experience, when using advanced photo manipulation software the quality will be greater than an automated process.
Best of luck.