Dual quaternions have important applications in fields such as information control, robotics, and hand-eye calibration. At the same time, matrix equations play a crucial role in system control, particularly the generalized Sylvester matrix equation AX+ EXF= CY+ D, which has extensive applications in higher-order linear systems. However, research on this matrix equation in the context of dual quaternions has not yet been discovered. Therefore, this paper aims to fill this research gap by establishing the necessary and sufficient conditions for the solvability of this generalized Sylvester matrix equation over dual quaternions and providing a general solution when it is consistent. As an application, we design a color image encryption and decryption scheme based on this generalized Sylvester matrix equation. Experimental results demonstrate the high feasibility and effectiveness of the proposed scheme.