It could be a security feature, as said already.
Otherwise it is against discrimination laws. As they can tell if you're male or female, which you don't have to tell them (unless it's a special job with an exemption, don't think this job is). They can tell your age, colour, possibly nationality and maybe some things I haven't thought of from a photo, none of which they are allowed to ask you about.
Obviously some jobs do require this information - for example, if you apply for a job in the home office and they ask this info, they specify why and outline how it still complies with discrimination laws.