Change required state by checking checkbox

I have an image field and a checkbox in my node edit form.
I want the image field to be required when the checkbox is not checked.
And I want the image field to not be required when the checkbox is checked.

How can I do this?