What law would this violate? Please be specific, as legal definitions of things like espionage are often not as broad as a layperson might guess (and on occasion, they're broader).
Once the party was informed, and thus had knowledge, of the national defense sensitivity involves, it would seem arguably to facially violate the Espionage Act of 1917, as amended; in particular, 18 USC §§ 793, 795, and, if they attempt to publish the pictures, 797, and/or, if the order originates with NASA, 799.
793 requires "intent or reason to believe that the information is to be used to the injury of the United States, or to the advantage of any foreign nation", but 795 and 797 could potentially apply. Thank you.
There's no way prosecutors and courts would actually commit to an Espionage Act conviction of an astronomer for looking at the wrong part of the sky. That's absurd.
Photographing and publishing or sending to unauthorized parties foreign or domestic, bet on it. You might get away with a stern visit from one of the 3-letter-agencies if it's minor importance and ignorance, but do it again...
If you doubt it, please do the test and report back the results.