I must say — we are not talking about the screenshots of the sites, although probably the solution will be fine for this.
You need to generate quite a large number of images from small pieces of html.
What ideas came to mind:
1) to Put on the server a thread and webkit to generate with it
2) Put mPDF
to convert html to pdf, then with the help of ImageMagick
konvertnut in jpg
In the first case — don't like the need to install additional software, it's rather platform specific solution.
The second is likely to suffer performance.
Who can faced and there is some easy solution? Ideally would be some sort of analog mPDF, only in JPG