Coarse-graining of complex networks is one of the important algorithms to study large-scale networks, which is committed to reducing the size of networks while preserving some topological information or dynamic properties of the original networks. Spectral coarse-graining (SCG) is one of the typical coarse-graining algorithms, which can keep the synchronization ability of the original network well. However, the calculation of SCG is large, which limits its real-world applications. And it is difficult to accurately control the scale of the coarse-grained network. In this paper, a new SCG algorithm based on K-means clustering (KCSCG) is proposed, which cannot only reduce the amount of calculation, but also accurately control the size of coarse-grained network. At the same time, KCSCG algorithm has better effect in keeping the network synchronization ability than SCG algorithm. A large number of numerical simulations and Kuramoto-model example on several typical networks verify the feasibility and effectiveness of the proposed algorithm.