modify ProcessStaticImg and decompose the file into several functions