PHP - How to generate thumbnails for images (png, jpg, gif, webp) with out Imagick
Thumbnails of images save bandwidth* and also increase user experience*. You could use Imagick but in some cases it may not be installed in your server.Here you will see how to generate thumbnails easily with out imagick.
We will use SimpleImage
Go to https://github.com/claviska/SimpleImage, download and extract SimpleImage.php.
generateThumbnail() returns true if a thumbnail is created and it will create thumbnails for PNG, JPG, GIF, WEBP formats
You can specify WIDTH and HEIGHT of your thumbnail image.By default it is 300. View code for more.
- To see it in action , go to https://github.com/thewebblinders/php-thumbnails-for-images, download and extract files.
- if you look at thumbnail-images folder, it will be empty
- Now run index.php on your server,you will see thumbnails being created in the folder thumbnail-images for the images located in source-images