Several models have been reported to predict the porosity during drying. However, currently these models do not allow quantifying the possible evolution of the initial air volume existing at the beginning of the drying process. In this study, a theoretical model was built to predict the porosity of dried materials by taking into account the possible changes in the initial air volume. The model involved two physical mechanisms (collapse and shrinkage phenomena) and was solved in Matlab by formulating it as a constrained optimization problem. The model predictions were extensively validated with experimental data published by several independent groups and compared with other models. In all cases, the proposed model gave a remarkable agreement with the literature data regardless of the porosity curve behavior and/or the presence/absence of inversion points. Furthermore, the shrinkage and collapse functions were used to get additional insights into the mechanisms of pore formation during air-drying and freeze-drying. The present model could be used as a reliable tool to accurately predict the porosity and to analyze the dynamic mechanisms involved during drying processes.