With the loss of two spacecraft reaction wheels precluding further data collection for the Kepler primary mission, even greater pressure is placed on the processing pipeline to eke out every last transit signal in the data. To that end, we have developed a new method to optimize the Kepler Simple Aperture Photometry (SAP) photometric apertures for both planet detection and minimization of systematic effects. The approach uses a per cadence modeling of the raw pixel data and then performs an aperture optimization based on signal-to-noise ratio and the Kepler Combined Differential Photometric Precision (CDPP), which is a measure of the noise over the duration of a reference transit signal. We have found the new apertures to be superior to the previous Kepler apertures. We can now also find a per cadence flux fraction in aperture and crowding metric. The new approach has also been proven to be robust at finding apertures in K2 data that help mitigate the larger motion-induced systematics in the photometry. The method further allows us to identify errors in the Kepler and K2 input catalogs.