The Size Depends On Which Consulate You Use
This is the single most important thing about a Mexican visa photo.
Mexico's Secretaría de Relaciones Exteriores publishes visa requirements consulate by consulate rather than as one national sheet, and the photo size is not consistent between them. The Embassy of Mexico in Ecuador states 'tamaño 3 x 3.5 centímetros'. Other missions state a passport-size 4.5 by 3.5 cm. Others give 3.9 cm x 3.1 cm, and some state a minimum and a maximum rather than a single figure.
This tool exports 30 x 35mm, the figure in the Ecuador sheet, because that is the document these numbers were read from directly. If the consulate you are applying to publishes something else, follow that instead — the frame here is a starting point, not a national standard.
It is worth saying why this matters more than usual. With most countries you can print one photo and use it anywhere. With Mexico, a photo cut to the wrong consulate's size is simply the wrong photo, and you will not find that out until the interview.