The breadth and depth of traditional Chinese medicine (TCM) applications have been expanding in recent years, yet the problem of quality control has arisen in the application process. It is essential to design an algorithm to provide blending ratios that ensure a high overall product similarity to the target with controlled deviations in individual ingredient content. We developed a new blending algorithm and scheme by comparing different samples of ginkgo leaves. High-consistency samples were used to establish the blending target, and qualified samples were used for blending. Principal component analysis (PCA) was used as the sample screening method. A nonlinear programming algorithm was applied to calculate the blending ratio under different blending constraints. In one set of calculation experiments, the result was blended by the same samples under different conditions. Its relative deviation coefficients (RDCs) were controlled within ±10%. In another set of calculations, the RDCs of more component blending by different samples were controlled within ±20%. Finally, the near-critical calculation ratio was used for the actual experiments. The experimental results met the initial setting requirements. The results show that our algorithm can flexibly control the content of TCMs. The quality control of the production process of TCMs was achieved by improving the content stability of raw materials using blending. The algorithm provides a groundbreaking idea for quality control of TCMs.