php - GD Thumbnail Creation - Is it possible tu run a script by short stages? -


I am using this modified script () to create thumbnails for all the images in a script:

  function vs thumb (images for $ path, $ pathtoombs, $ thumbbyte, $ image quality) {$ dir = opendir ($ pathToImages); While (wrong! == ($ fname = readdir ($ dir))) {$ info = pathinfo ($ pathToImages. $ Fname); If (stroller ($ info ['extension']) == 'jpg') {$ img = imagecreatefromjpeg ("{$ pathToImages} {$ fname}"); $ Width = imagesx ($ img); $ Height = images ($ IMG); $ new_width = $ thumbWidth; $ new_height = floor ($ height * ($ ring width / $ width)); $ tmp_img = imagecreatetruecolor ($ new_width, $ new_height); imagecopyresized ($ tmp_img, $ img, 0, 0, 0, 0, $ new_width, $ new_height, $ width, $ height); Imagejpeg ($ tmp_img, "{$ pathToThumbs} {$ fname}", $ imageQuality)}} Monkey ($ dir);}   

I have to create more than 250 thumbnails, The reason is not limited execution time. If possible I use set_time_limit ()

  (function_exists ('set_time_limit') == true and @ini_get ('safe_mode') == 0) {@set_time_limit (9000); }   

But there is no way to modify these i settings - there is no way to convert the images to such steps in such steps as: Create 10 thumbs & gt; Header ('location: ./function=createThumbs') & gt; Make the next 10 thumbs .. until all the thumbs are ready. Thanks in advance for any help!

To execute the script for a long period, you can set_time_limit (0) That there will be no limit to the execution time of the script. But setting it to zero will not work because the browser will not show you any output for a specific period.

One way to avoid this may be some output after each, using thumbnails generation such as auditor () and flush () by using functions in PHP.

Another option (which I strongly recommend for such high time-consuming job) is to use the process control tool as if you were to exit the script and process the request separately. to do. The advantage of this is that, when you are making thumbnails, the end user will be free to move to the other sections of your website. Gearman provides you a way to keep your job in the background so that control is returned to your PHP scripts and work Once complete, you can shoot an email to the user or show some information on your site using the AJAX pull mechanism. / P>

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -