Skip to content

Instantly share code, notes, and snippets.

View zaw-hlaing-bwar's full-sized avatar

Zaw Hlaing Bwar zaw-hlaing-bwar

View GitHub Profile
@pedroppinheiro
pedroppinheiro / create_thumbnail.php
Last active June 21, 2019 17:14
This php funtion creates a thumbnail of an image. It supports JPEG, JPG, PNG and GIF formats and can be used to define a specific background color, including transparent when dealing with PNG.
<?php
/**
* This code is an improvement over Alex's code that can be found here -> http://stackoverflow.com/a/11376379
*
* This funtion creates a thumbnail with size $thumbnail_width x $thumbnail_height.
* It supports JPG, PNG and GIF formats. The final thumbnail tries to keep the image proportion.
*
* It has been pointed out that if the thumbnail already exists it doesn't get overwritten, but the method still returns true.
* so keep an eye on that.
*