Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8286303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:41:54+00:00 2026-06-08T11:41:54+00:00

I was doing this in a manual way, but i was thinking there may

  • 0

I was doing this in a manual way, but i was thinking there may be a more automatic way to do this. The below script has to resize 1000 folders with more than 100K images collectively in each folder (Not 100K in each folder). I only have two minutes of max_execution_time for it to run. It can do about 10 folders in two minutes. But, really I just want the script to pause before two minutes is up…then start again where it left off..hopefully, restarting it’s max_execution_time. I don’t know if sleep() can do that – sleep may count toward execution time, not sure.

The manual way was increasing the $count variable by 10 and then increasing the i$ in the while loop by 10 as well. Therefore it would start where it left off, doing 10 folders at a time. Refresh to run it. At the moment I have no cron access, either.

Here’s the script…

class DevTestHelper {


//This will Go through all full size images and resize images into requested folder
function resizeGalleryImages($destFolder, $width, $height, $isCrop = false) {

$count = 1000;

$source = JPATH_SITE."/images/gallery/full";
$dest = JPATH_SITE."/images/gallery/".$destFolder;

echo 'Processing Images<br>';

//Loop through all 1000 folders 0 to 999 in the /full dir
for($i=0; $i < $count;$i++) {
    $iPath = $source.'/'.$i;
    if(is_dir($iPath)) {

            $h = opendir($iPath);
            //Loop through all the files in numbered folder
            while ($entry = readdir($h)) {

         //only read files
                if ($entry != "." && $entry != ".." &&        !is_dir($entry)) {
          $img = new GImage($source.'/'.$i.'/'.$entry);

                    $tmp = $img->resize($width, $height, true, 3);

                    if($isCrop) {
                        $tmpWidth = $tmp->getWidth();
                        $tmpHeight = $tmp->getHeight();

                        $xOffset = ($tmpWidth - $width) / 2;
                        $yOffset = ($tmpHeight - $height) / 2;

                        $tmp->crop($width, $height, $xOffset, $yOffset, false, 3);
                    }

                    $destination = $dest.'/'.$i.'/'.$entry;

                    if(!$tmp->toFile($destination)) {
                        echo 'error in creating resized image at: '.$destination.'<br>';
                  }

                 //echo $entry.'<br>';
        }

            }

        echo 'Processed: '.$i.' Folder<br>';

    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T11:41:56+00:00Added an answer on June 8, 2026 at 11:41 am

    You have a few different options:

    1. Have a script that populates a queue and another script that processes the queue.
    2. Spawn multiple worker scripts to handle the processing in parallel
    3. After each resize, extend the script timeout using set_time_limit(x) within your loop so that as long as the data is being processed successfully, it will keep running
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing this with a very simple class, just to learn, but I'm not
I have trouble doing this... You may want to get the same result as
Is there a way to do this: I need to develop the easiest way
I am doing manual drawing of text with CGContextShowTextAtPoint() because this text is being
Im doing this project where i need to download files through a webservice (images,
I am interested in doing this C code in Java: // sets n's ith
I am doing this currently, class Page { // variable to hold DBC class
I'm doing this interface where I have a lot of buttons that are just
So I am doing this query from PHP, and here listerally the exact query
Think about doing this: import matplotlib.pyplot as plt plt.plot(x_A,y_A,'g--') plt.plot(x_B,y_B,'r-o') plt.show() How would you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.