At present times, medical image security becomes a hot research topic in the healthcare sector. This paper presents an efficient lightweight image encryption model based on the Dynamic key generating Attribute based encryption (ABE) method with Opposition based joint Grey Wolf-Whale Optimization Algorithm (OjGW-WOA). The proposed encryption method undergoes certain pre-encryption steps like rotation and random column addition steps. Once the pre-encryption steps are done, ABE with OjGW-WOA is incorporated, where the optimal key is generated based on entropy value. In addition, the oppositional based learning (OBL) concept is introduced to enhance the convergence rate and searching process of GWO and WOA algorithms. Next, the proposed encryption method is designed with a dynamic key generating model that generates updated keys during every time period. Therefore, during decryption, two-level key verification is done. At the first decryption stage, the key corresponding to that particular time period is required, then the original key is generated from that key and then employed for decrypting the original data. The proposed method is simulated using MATLAB tool and a detailed comparative results analysis is carried out. The performance of the proposed work is validated with the aid of performance metrics like Peak Signal to Noise Ratio (PSNR), number of changing pixel rate (NPCR) and unified averaged changed intensity (UACI). The experimental results stated that the presented model has resulted to a higher PSNR of 62.29dB, NPCR of 99.23%, and UACI of 23.67%.