How do you know the difference in pneumonia and TB on a chest x-ray?

Looks different. Pneumonia is a patchy or consolidated infiltrate, and TB are smaller cavitay lesions or spots in the lung.
Chest x-ray pattern. Tb is a kind of pneumonia ( or lung infection) caused by a specific bacteria ( mycobacterium tuberculosis). It is suggested by an x ray where the infection affects the upper lobes of the lungs, and where there is a cavity or "hole" in the lung produced by the infection. Non of this is 100% predictive of the bacteria however and TB is confirmed by finding the germ in the sputum.