ArchivedTools/ScanScripts/Windows/simplex_scanned_sort.php

40 lines
775 B
PHP
Raw Permalink Normal View History

2023-12-21 00:48:37 +00:00
<?php
// Sorts images which has first been scanned face up,
// then scanned face down using ADF simplex scanning on double
// sided pages.
$files = glob("input/*.tif");
$count = count($files);
$split = $count / 2;
$outdir = "./output/";
$counter = 1;
$pagenum = 1;
@mkdir($outdir);
while ($counter <= $split)
{
echo $counter . " ";
print_r($files[$counter-1]);
copy($files[$counter-1], $outdir . str_pad($pagenum, 4, 0, STR_PAD_LEFT) . '.tif');
echo " " . $pagenum ."\r\n";
$counter++;
$pagenum += 2;
}
echo $counter;
$pagenum--;
while ($counter <= $count)
{
echo $counter . " ";
print_r($files[$counter-1]);
copy($files[$counter-1], $outdir . str_pad($pagenum, 4, 0, STR_PAD_LEFT) . '.tif');
echo " " . $pagenum ."\r\n";
$counter++;
$pagenum -= 2;
}