http://www.cit.gu.edu.au/~anthony/graph ... #jpg_write
NOTE: You can not determine a quality to get a specific filesize, except by trying it. The best way is to say try (a quality of) 75% and see the result if to large reduce by 10%, if two small increase. Then do a binary search to find the quality that best matches what file size you want. Shouldn't take more than 5 to 6 trys to figure it out.
Of course you did not specify JPEG, though that is probably the most common for general images. But we can't help you much further without knowning what format you are using.