Some old PHP code I found, used to create thumbnails.