GD library - reduce quality/filesize

I have a script that sizes images and makes a thumbnail. It works well but often if a user adds a large image, the resized image is the correct physical size but the file-size is too big and could make the page load slowly.
Is there anyway that I can reduce the quality/resolution of the image to make it fit below a set filesize, or jus set the overall quality to 60% or something like that?

I Do not belive you can easily decide on a final image size or percent wothout resizing the image getting the image size and if it is still to big resize again.

The only way is set the image quality in the save command; see: imagejpeg