I hope you want to turn the 1-5 value into an actual star performance.
It depends on how competent you are, I think that Amazon is accurate to the tenth (0.1), probably this is the server side to save on client load and use image caching; but this can be done on the client side.
@kingjiv posted a good solution on the client side, but for the server side:
If you are not too concerned about detailing, you can create 11 images of 0, 0.5, 1, 1.5, etc. and pass the value to the src attribute of the image. This will serve the right image and they will be nicely cached for reuse over and over on your pages.
If you want to be truly granular, although you can create them on the server side of the code, cache them each time you create them, ready for quick maintenance later. With this method, you could go to any degree of accuracy that has taken your imagination.
For PHP, I would recommend looking at Imagik
source share