Given the specific IDs of the two elements you don’t want to affect:
$('img').not('#id1').not('#id2').addClass('myclass');
or:
$('img').not('#id1,#id2').addClass('myclass');
or:
$('img:not(#id1,#id2)').addClass('myclass');
2
solved How to add a class to all images except specific ones with JS