Recently various physical systems have been proposed for modeling Ising spin Hamiltonians appealing to solve combinatorial optimization problems with remarkable performance. However, how to implement arbitrary spin-spin interactions is a critical and challenging problem in unconventional Ising machines. Here, we propose a general gauge transformation scheme to enable arbitrary spin-spin interactions and external magnetic fields as well, by decomposing an Ising Hamiltonian into multiple Mattis-type interactions. With this scheme, a wavelength-division multiplexing spatial photonic Ising machine (SPIM) is developed to show the programmable capability of general spin coupling interactions. We exploit the wavelength-division multiplexing SPIM to simulate three spin systems: ±J models, Sherrington-Kirkpatrick models, and only locally connected J1-J2 models and observe the phase transitions. We also demonstrate the ground-state search for solving Max-Cut problem with the wavelength-division multiplexing SPIM. These results promise the realization of ultrafast-speed and high-power efficiency Boltzmann sampling to a generalized large-scale Ising model.