Wasn’t easy to find a working solution, so I’m posting here as a reminder.

This is a PHP function to generate images thumbnails that handles: png, jpg, gif and also transparency

I’m not the author of this function, I’ve just mixed two solutions together, and fixed some small issues.

Sources :