Measurements of charged pion and kaon production are presented in centrality selected Pb+Pb collisions at 40A GeV and 158A GeV beam energy as well as in semi-central C+C and Si+Si interactions at 40A GeV. Transverse mass spectra, rapidity spectra and total yields are determined as a function of centrality. The system-size and centrality dependence of relative strangeness production in nucleus-nucleus collisions at 40A GeV and 158A GeV beam energy are derived from the data presented here and published data for C+C and Si+Si collisions at 158A GeV beam energy. At both energies a steep increase with centrality is observed for small systems followed by a weak rise or even saturation for higher centralities. This behavior is compared to calculations using transport models (UrQMD and HSD), a percolation model and the core-corona approach.