![]() I am using all JPEG/JPG image so I have used imagecreatefromjpeg(). I iterate over the scanned directory and on each image file I apply the resize with the mentioned width and height. ( array('.', '.')) from Unix like systems. Notice I have used array_difference() to exclude. Then I have scanned the image folder using scandir(). This directory in kept under the project’s root folder. Next I have create an image directory ( images) where I will put all my images. So I have set it to 5 minutes by adding the line ini_set('max_execution_time', 300) You can also set temporary time limit using set_time_limit(300). After updating php.ini file you need to restart the Apache HTTP Server to reflect the change.Īs the bulk operation is going on, so your server might have been configured with timeout for PHP file execution. You can also set the memory limit in php.ini file using the line memory_limit = -1. ![]() For example, you may see the error: Allowed memory size of 134217728 bytes exhausted. I have added ini_set('memory_limit', '-1') to avoid memory issue while the PHP file gets executed for bulk operation. I have create a PHP file called php-bulk-images-resize.php and put the following source code. Now I will show you how to resize multiple or bulk images. I may not mention the project root directory in subsequent sections and I will assume that we are talking with respect to the project root directory. Now we will create a project root directory called php-bulk-images-resize under the Apache server’s htdocs folder. It’s assumed that you have setup Apache and PHP in Windows system. PrerequisitesĪpache HTTP Server 2.4, PHP 7.4.3 Project Directory If you do not want to replace the original image then you can rename the resized image. ![]() So the original image will be replaced by the resized image. In this example I am going to scan a particular directory that contains bulk images and one by one I will resize and save the image in the same directory. Such functions are scandir(), imagecreatetruecolor(), imagecreatefromjpeg(), imagecopyresized() and imagejpeg(). I am going to use built-in functions from PHP language to scan the directory and resize images. Here in this tutorial I am going to show you how to resize multiple images or bulk images using PHP programming language.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |