The inherent issue associated with any digital image is its underlying redundancy and large dimension, which require a huge amount of storage space and higher bandwidth for transmission over a wireless channel. This factor has inspired the researchers to arrive at the optimal resolution that compresses digital images based on their content type and also achieves better visual quality. The proposed work aims at compressing the images according to the contrast variations by hybridizing discrete wavelet transform (DWT) and machine learning (ML) techniques for quality reconstruction. It includes two operation phases. In the initial phase, the ML model is first trained with a training set containing various image data. The second stage is mainly subjected to performing image compression and decompression by employing the joint approach of the transform technique and a trained ML model. Compression involves the application of two-level DWT to the image, then each sub-band is divided into non-overlapping blocks, and a decision is made for each block based on the block variance. Each block is subjected to the extraction of structural features, that are next Huffman encoded, and finally, these features are employed in image reconstruction. Reconstruction involves querying each block feature with a pre-trained K-nearest neighbour (K-NN) model. Experiments have been conducted, and the effectiveness of the proposed system is analyzed in terms of peak signalto-noise ratio (PSNR), mean squared error (MSE), structural similarity index measure (SSIM), and compression ratio (CR). Comparative assessments against prior methods reveal superior visual quality metrics and computation time, with custom real-time image testing confirming its outperformance over current approaches. Notably, the proposed work achieves a PSNR of 53.2093 dB for the "Saras" image, SSIM values of 0.9997 for "Cameraman," and a nearly 5% increase in PSNR levels compared to existing techniques, substantiating its efficacy in content-based image compression.