I think that in essence this could be solved contractually when the project begins by stating within that original contract what the rights of the contractor and client are in relation to images produced.
By explicitly laying this out in the original agreement it does a number of things:
Instigates the discussion about rights at the offset of the project so that everyone understands where they stand, and it is at this point both can negotiate.
Clarifies to the client that no matter what method the contractor uses to attain the image, they still hold some rights to the image.
Lays out what those rights are for both parties.
If it comes to litigation for some reason, the Judge would have information regarding what agreements had been discussed by the two parties, which could in fact affect the decision.
I too don't think this ruling would stand up in the scrutiny of an appeal, but the lesson here is to not assume that you have rights over images you have created without actually attempting to assure that you do,