Recently, to offer better ensure for image privacy security, numerous new image encryption algo-rithms have been proposed. However, these algorithms still suffer from the problems of chaotic per-formance scarcity, low encryption effect, and high consumption of computational resources. To solve the above issues, we first construct a two-dimensional modular hyperchaotic map (2D-MHM). Then, we further develop an image encryption algorithm based on 2D-MHM and compressed sensing (CS). Several chaotic metrics verify the randomness and validity of 2D-MHM. These metrics include bi-furcation diagram, Lyapunov exponent, initial value sensitivity, 0-1 test, and NIST test. Specifically, CS significantly reduces the ciphertext image size thereby reducing its resource consumption during transmission. Reality-preserving fractional DCT (RP-Fdct) diffusion is utilized to transform pixels into the frequency domain to enhance the encryption effect. Subsequently, lightweight index confu-sion and XOR diffusion further improve the algorithm security. The security of the algorithm is veri-fied through various experiments. It is able to encrypt grayscale and color images of different sizes with good results. Notably, this algorithm also implements the encryption requirements for binary images. Due to our designs, it outperforms recently reported encryption algorithms in several areas, especially in reconstruction performance.