Pneumonia is a lung inflammation that mostly affects the tiny air sacs known as alveoli. The disorder can range in severity. The most prevalent causes of pneumonia are infections with viruses or bacteria, other microbes, or certain drugs. Cystic fibrosis, chronic obstructive pulmonary disease (COPD), asthma, diabetes, heart failure, a history of smoking, having a defective cough reflex, such as after a stroke, and having a weakened immune system are risk factors. The physical exam and symptoms are frequently used to make a diagnosis. One of the most common illnesses that are challenging to diagnose because of a shortage of professionals is pneumonia. Early and accurate diagnosis is crucial for effective treatment and better patient outcomes. Pneumonia, along with Covid-19, became one of the more serious medical conditions. The most popular procedure for diagnosis is a chest X-ray. In recent years, deep learning-based approaches have shown great promise in automated pneumonia detection using chest X-ray images. However, examining a chest X-ray is a difficult task. It follows that automated diagnostic systems are necessary. Hence one such system is the proposed CNN model described in this paper with an accuracy of 97.02%. It comprises of image enhancing techniques specially designed for X-ray images and the proposed CNN model.