Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A secondary approach would be to log processed filename to a log file and compare against directory listing to see if it has been processed.</p> <p>untested again:</p> <pre><code>&lt;?php // Open log file so we can read and put processed image name onto array $imageLogFilename = 'image.log'; $fh = fopen($imageLogFilename,'a+'); $processedFileNames = array(); $newProcessedFileNames = array(); // Read file line by line and add filename onto an array if($fh) { while (($line = fgets($fh)) !== false) { $processedFileNames[] = trim($line); } fclose($fh); } else { die('error - could not open log for reading'); } $imageDirectory = "/home/public_html/images/"; // Path to your images // Read all files in image directory. (You could put this in a function and call recursively if you have child directories.) $files = scandir($imageDirectory); foreach($files as $file) { if($file == '.' || $file == '..') { continue; } // check if this image is in the already processed image array if(in_array($file, $processedFileNames) === false) { // your resize code here if($resizeResult == false) { die('Image Resizing Failed'); } } // Store all images on new array $newProcessedFileNames[] = $file; } if(count($newProcessedFileNames) &gt; 0) { // open logfile again but this time truncate and update with latest image filenames, so its up to date for next run. $fh = fopen($imageLogFilename,'w'); if($fh) { foreach($newProcessedFileNames as $filename) { fwrite($fh,$filename . PHP_EOL); } fclose($fh); } else { die('error - could not write to log file'); } } fclose($fh); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload