Detect when a texture should be imported as a normal map

I am trying to build an automated import process for artists to send models with all the textures in a zip file and do some auto-import magic. Is there a way to tell from a texture if it is a normal map in a procedural way? From a human point of view, normal maps are very obvious with their blueish tint, but would there be a way for a computer to come to the same conclusion using simple logic?

Assuming you’re only using the standard normal map format (and not, for example, using Unity to generate them from grayscale), I would evenly sample maybe 100 pixels, convert them from RGB to XYZ, and average them. If they are within a tolerance limit (you would have to play with that to get it right), you could assume it’s a normal map. You may get some false positives, but it should generally work.

Another way would be to sample the pixels and check if, when converted, they are roughly unit vectors. A standard RGB image would result in vectors of varying lengths, but a properly formatted normal map would typically pre-normalize before encoding into RGB.

The last way, and the best in my opinion, would be to do it with metadata. You could have the artists include a text file with a specific format in the zip files that tells the importer what each texture applies to, much like the OBJ model format’s material files.