The JPEG algorithm is one of the most used tools for compressing images. The main factor affecting the performance of the JPEG compression is the quantization process, which exploits the values contained in two tables, called quantization tables. The compression ratio and the quality of the decoded images are determined by these values. Thus, the correct choice of the quantization tables is crucial to the performance of the JPEG algorithm. In this paper, a two-objective evolutionary algorithm is applied to generate a family of optimal quantization tables which produce different trade-offs between image compression and quality. Compression is measured in terms of difference in percentage between the sizes of the original and compressed images, whereas quality is computed as mean squared error between the reconstructed and the original images. We discuss the application of the proposed approach to well-known benchmark images and show how the quantization tables determined by our method improve the performance of the JPEG algorithm with respect to the default tables suggested in Annex K of the JPEG standard.