Managing medical images securely and efficiently is a growing challenge, especially as modern imaging technologies produce color and high-bit-depth files that are both large in size and highly sensitive. To address this, a two-stage framework is proposed that combines precision compression with resilient encryption. The beginning stage is Key-Pixel Predictive Modeling for Lossless Compression (KPPMLC), reduces storage requirements by selecting a small number of mandatory pixels and by applying a context-aware neural network to accurately reconstruct the rest. KPPMLC is built completely using deterministic and reversible operations, that approach enables a perfect image reconstruction, with support for both grayscale and RGB formats up to 16 bits per channel. The next stage which is named as Hybrid Quantum-Classical Magic Square Generator (HQCMSG), builds 256×256 cryptographic magic square matrices using a combination of classical backtracking and quantum optimization based on QUBO. A coordinating mechanism keeps monitoring both paths and selects the first valid result, which helps to maximize randomness and to improve the encryption strength. Together, these modules provide a compact, lossless, and future-proof system for the secure handling and transmission of medical images. Evaluation on a CE-T1 MRI dataset (3,064 images) shows that QCMSE achieves bit-exact reconstruction (MSE = 0) for grayscale and RGB images up to 16-bit depth. It reduces average encryption and decryption times to 3962.6 mS and 4,026.6 mS, outperforming existing methods by up to 25.3% and 23.9%, respectively. Strong security is validated by an average NPCR of 99.83%, UACI of 34.15%, and an overall security score of 98.38%, confirming robustness against statistical and differential attacks.