A simple and reusable function for generating thumbnails dynamically from PHP