123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
<?
//dont change this value
set_time_limit(10000000);
function leading_zeros($value, $places){
// Function written by Marcus L. Griswold (vujsa)
// Can be found at http://www.handyphp.com
// Do not remove this header!
if(is_numeric($value)){
for($x = 1; $x <= $places; $x++){
$ceiling = pow(10, $x);
if($value < $ceiling){
$zeros = $places - $x;
for($y = 1; $y <= $zeros; $y++){
$leading .= "0";
}
$x = $places + 1;
}
}
$output = $leading . $value;
}
else{
$output = $value;
}
return $output;
}
//$start = microtime(true);
//location of the completed film images
//$filepath=$PATH.'C:\\Calloway\\Source\\Drawer170\\Film Images\\Completed\\';
$filepath=$PATH.'C:\\Ballard\\Film Images\\Completed\\';
//same as filepath
//$dir = opendir('C:\\Calloway\\Source\\Drawer170\\Film Images\\Completed\\');
$dir = opendir('C:\\Ballard\\Film Images\\Completed\\');
while($file = readdir($dir)){
if(eregi("\.tif", $file)) {
$filepare = ltrim(str_replace('.TIF','',$file),0);
$filepare = ltrim(str_replace('.tif','',$filepare),0);
$fileparear = explode('-',$filepare);
$filenumber = $fileparear[0];
$pagenumber = leading_zeros($fileparear[1],4);
$fullname = $filenumber."-".$pagenumber;
$listarray[$filenumber][] = $fullname;
}
}
//same as filepath
//$source = 'C:\\Calloway\\Source\\Drawer170\\Film Images\\Completed\\';
$source = 'C:\\Ballard\\Film Images\\Completed\\';
//target directory for combined film images
$target = 'C:\\Ballard\\Film Images\\Final\\';
foreach($listarray as $key => $value){
sort($value);
$j=0;
foreach($value as $key2 => $value2)
{
if($key > 0){
$renamear = explode('-',$value2);
$renamefirst = leading_zeros($renamear[0],4);
$renamesecond = ltrim($renamear[1],0);
if($renamesecond != NULL){$rename = $renamefirst."-".$renamesecond;}
else {$rename = $renamefirst.$renamesecond;};
$list .= ",".$source.$rename.".tif"; $j++;}}
$combine = $target."FinishedFilm\\".$key.".tif".$list;
$command = '"C:\Program Files\IrfanView\i_view32.exe" /tifc=4 /multitif=('.$combine.') /killmesoftly';
if ($j < 1000000000){
echo $command;
//comment the next 2 lines to test
//$file = popen($command, "r");
//pclose($file);
echo "<br>";}
unset ($list);
}
$end = microtime(true);
$time = $end-$start;
echo $time;
?>