When a gun is fired, it leaves marks on cartridge cases that are thought to be unique to the gun. In current practice, firearms examiners inspect cartridge cases for "sufficient agreement," in which case they conclude that they come from the same gun, testifying in courts as such. A 2016 President's Council of Advisors on Science and Technology report questioned the scientific validity of such analysis (President's Committee of Advisors on Science and Technology, Washington, DC, Executive Office of the President). One recommendation was to convert firearms analysis to an objective method. We propose a fully automated, open-source method for comparing breechface marks on cartridge cases using 2D optical images. We improve on existing methodology by automating the selection of marks, and removing the effects of circular symmetry. We propose an empirical computation of a "random match probability" given a known database, which can be used to quantify the weight of evidence. We demonstrate an improvement in accuracy on images from controlled test fires.