The size of files compressed with JPEG vary depending on the complexity of the image. Trying the control the file sizes the way you describe will result in highly variable perceived image quality.
Just use a quality setting that you find acceptable, like 75. Compare the size of the result with the original image, and keepConsider the smaller file. See What quality to choose when converting to JPG?following options instead:
Or consider using a JPEG minimizer, like JPEGmini or jpeg-recompress
from jpeg-archive. They are essentially designed to do what you seem to be trying to do, but with more awareness of JPEG algorithm internals.
The good-enough approach. Use a quality setting that you find acceptable, like 75. Compare the size of the result with the original image, and keep the smaller file. See What quality to choose when converting to JPG?
Use a JPEG minimizer, like JPEGmini or
jpeg-recompress
from jpeg-archive. They are essentially designed to do what you seem to be trying to do, but with more awareness of JPEG algorithm internals.Generate thumbnails of various sizes, as Nathancahill suggests, from a web-developer perspective.