As medical imaging technologies continue to proliferate and generate massive amounts of data, data compression has become increasingly important for their storage, transit, and processing in the modern world. In telemedicine practices, it is common for medical images to be sent from one site to another. It is now important to minimize image size while maintaining diagnostic information in order to transmit and keep these high-quality images. Medical images compression is a technique that helps save money on transfer and storage by advising on the use of lossy and lossless compression algorithms. Medical images compression calls for a machine learning and IOT infrastructure. Multistage PCA, the Discrete Anamorphic Stretch Transform, and PCA using the Johnson-Lindenstrauss Lemma algorithm are just a few examples of dimensionality reduction techniques used in image compression. We provide many options for decreasing the dimensionality of image data. Among these techniques are PCA using the Johnson-Lindenstrauss Lemma algorithm, Discrete Anamorphic Stretch Transform, and Multistage Principal Component Analysis. The research suggests that combining PCA based on the Johnson-Lindenstrauss lemma with Shannon-Fano coding can lead to significant compression gains.