Determining if a picture is taken from a camera or a gallery

So my question is exactly as I said above. I’m not sure if this is the correct forum, do let me know if im wrong though.

One way I thought of is to extract data from the picture? and check it against the current time? if the picture taken has time similar to my current time, I can assume its from the camera?Would that flow of logic work in a sense?

Anyone have any other ideas?