Stupid question: wouldn't a simple comparison with the body(parts) from the inappropriate pictures sent to the girl have helped the innocent guy? I mean those thingies all look different, no, like some sort of "fingerprint"?
Any number of things could have acquitted this man, including that. His lawyer, the judge, the prosecutors, the police and anyone else involved at any stage of this case need to be looked at very carefully and hard decisions should be made about whether it's appropriate for them to be licensed to perform whatever duties they were performing in the course of it.
The prosecution certainly could have done a comparison, but it seems they just went with the matching username and figured it was a slam-dunk (which it turned out to be). It's very possible the defense was never even made aware of those photos, and thus had no recourse for challenging them.