Created
July 6, 2012 15:40
-
-
Save pkdavies/3060960 to your computer and use it in GitHub Desktop.
PHP based high resolution image combiner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$oldpath = "./in/"; | |
$newpath = "./out/"; | |
$dir_iterator = new RecursiveDirectoryIterator($oldpath); | |
$iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST); | |
$files_all = $files_copied = $files_replaced = 0; | |
foreach ($iterator as $file) { | |
if ($file->isFile()) { | |
$size = $file->getSize(); | |
$newfile = strtolower($file->getFilename()); | |
if (file_exists($newpath.$newfile) && filesize($newpath.$newfile) < $size){ | |
if (!copy($file->getPathname(), $newpath.$newfile)) { | |
echo "failed to copy...\n"; | |
} else { | |
echo "found larger file and copied...".$file->getPathname()."\n"; | |
$files_replaced++; | |
} | |
} else { | |
if (!copy($file->getPathname(), $newpath.$newfile)) { | |
echo "failed to copy...\n"; | |
} else { | |
echo "file copied...".$file->getPathname()."\n"; | |
$files_copied++; | |
} | |
} | |
} | |
$files_all++; | |
} | |
echo "---------- ALL DONE -------------------\n"; | |
echo "All files = $files_all \n"; | |
echo "Copied files = $files_copied \n"; | |
echo "Replaced files = $files_replaced \n"; | |
echo "---------------------------------------\n"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment