Hundreds of millions of people worldwide use computing devices and services, including smartphones, laptops, and messaging apps. Visual cryptography (VC) is one of the most secure encryption methods for image encryption in many applications, such as voting security, online transaction security, and privacy protection. An essential step in VC is encrypting secret images into multiple digital shares to hide them with the intention of successfully reverting them to their original form. Hence, a single share cannot reveal information about the secret image. Issues including pixel enlargement, high processing costs, and low decryption quality influence the current state of VC. We address these issues by introducing a novel technique based on (2, 2) secret sharing and the algorithm of Harris hawks optimization (HHO) for color photos. For the encryption process, the appropriate color levels are determined using the HHO algorithm. Consequently, images are decrypted with improved quality and a small impact on the overall processing complexity. The suggested scheme is also non-expandable due to the equal size of the initial secret image and the shared images. This results in lower memory requirements and improved image quality. The approach is applied to a set of well-known benchmark images. Moreover, a set of standard metrics is used to assess the robustness of the proposed scheme, including its capability in defending against cryptanalytic attacks, a correlation, a histogram, and the quality of encryption. According to the findings, the proposed solution provides better reconstructed image quality, time-efficient encryption, and nearly optimal statistical properties compared to previous approaches.