How to add class to the last image of the last post in a loop

Why don’t you use CSS pseudo attributes for that.
You can simply use :first-child and :last-child to target first and last element for CSS styling.

Here is how you do that with CSS pseudo attributes.

div.post:last-child div.testing_imran img {
    your styles for last image
}

Also FYI, your code will work too, if you want to target last image in CSS file. You don’t really need to add CSS class to image itself, but adding CSS class to div container will work fine too.

div.testing_imran.imd_last img {
    your styles for last image
}

If you want to targe image in jQuery, then same rules work for jQuery too.