1. A method ( 400 ) of compressing a digital image including a matrix of elements each one consisting of a plurality of digital components of different type representing a pixel, the method comprising the steps of: splitting ( 455 ) the digital image into a plurality of blocks and calculating, for each block, a group of DCT coefficients for the components of each type, quantizing ( 460 - 465 ) the DCT coefficients of each block using a corresponding quantization table scaled by a gain factor for achieving a target compression factor, characterized by the steps of determining ( 440 ) at least one energy measure of the digital image, estimating ( 441 - 450 ) the gain factor as a function of the at least one energy measure, the function being determined experimentally according to the target compression factor.