This commit is contained in:
2019-11-06 10:54:26 -08:00
parent 8531a96140
commit a13cdb85e3
3 changed files with 14 additions and 8 deletions

View File

@@ -1,3 +1,7 @@
[0.9.0.1]
- Better tmp dir
[0.9.0.0] [0.9.0.0]
- Added output levels option - Added output levels option

View File

@@ -1 +1 @@
0.9.0.0 0.9.0.1

View File

@@ -3,9 +3,11 @@
// Leaf - Tools for Book Scans // Leaf - Tools for Book Scans
// No license, do not distribute // No license, do not distribute
$version = "0.9.0.0"; $version = "0.9.0.1";
$time_start = microtime(true); $time_start = microtime(true);
date_default_timezone_set("America/Los_Angeles"); date_default_timezone_set("America/Los_Angeles");
$tmpdir = "/tmp/".time();
mkdir($tmpdir);
// Detect cores // Detect cores
@@ -1049,12 +1051,12 @@ foreach ($files as $file) {
$ext = pathinfo($file,PATHINFO_EXTENSION); $ext = pathinfo($file,PATHINFO_EXTENSION);
$output = $dest."/".basename($file,$ext)."jpg"; $output = $dest."/".basename($file,$ext)."jpg";
$msg = "Creating hough composite from ".$file; $msg = "Creating hough composite from ".$file;
$cmd = "convert ".$file."[".$size."x".$size."] -auto-orient \( +clone -canny ".$canny." -write /tmp/".basename($file)."_canny.png "; $cmd = "convert ".$file."[".$size."x".$size."] -auto-orient \( +clone -canny ".$canny." -write ".$tmpdir.basename($file)."_canny.png ";
$cmd .= "-background none -fill red -stroke red -strokewidth 1 -hough-lines ".$hough." -write /tmp/".basename($file)."_lines.png \) "; $cmd .= "-background none -fill red -stroke red -strokewidth 1 -hough-lines ".$hough." -write ".$tmpdir.basename($file)."_lines.png \) ";
$cmd .= "-composite ".$output; $cmd .= "-composite ".$output;
$thread[] = array($msg, $cmd); $thread[] = array($msg, $cmd);
$msg = "Creating MVG file from ".$file; $msg = "Creating MVG file from ".$file;
$cmd = "convert /tmp/".basename($file)."_canny.png -hough-lines ".$hough." ".$output.".mvg"; $cmd = "convert ".$tmpdir.basename($file)."_canny.png -hough-lines ".$hough." ".$output.".mvg";
$thread[] = array($msg, $cmd); $thread[] = array($msg, $cmd);
} }
@@ -1216,10 +1218,10 @@ if (ask("Create spreads? (Y/n)") != "n") {
$left = $ops[($key*2)]; $right = $ops[($key*2)+1]; $left = $ops[($key*2)]; $right = $ops[($key*2)+1];
$ext = pathinfo($left[0],PATHINFO_EXTENSION); $ext = pathinfo($left[0],PATHINFO_EXTENSION);
$lfile = $left[0]; $rfile = $right[0]; $lfile = $left[0]; $rfile = $right[0];
$tmpleft = "/tmp/".basename($left[1]); $tmpright = "/tmp/".basename($right[1]); $tmpleft = $tmpdir.basename($left[1]); $tmpright = $tmpdir.basename($right[1]);
if ($ext == "DNG" && getjpg($left[0]) && getjpg($right[0])) { if ($ext == "DNG" && getjpg($left[0]) && getjpg($right[0])) {
$lfile = getjpg($left[0]); $rfile = getjpg($right[0]); $lfile = getjpg($left[0]); $rfile = getjpg($right[0]);
$tmpleft = "/tmp/".basename($left[1],$ext)."JPG"; $tmpright = "/tmp/".basename($right[1],$ext)."JPG"; $tmpleft = $tmpdir.basename($left[1],$ext)."JPG"; $tmpright = $tmpdir.basename($right[1],$ext)."JPG";
} elseif ($ext == "DNG") { } elseif ($ext == "DNG") {
echo "-"; echo "-";
continue; continue;
@@ -1227,7 +1229,7 @@ if (ask("Create spreads? (Y/n)") != "n") {
copy($lfile,$tmpleft); copy($rfile,$tmpright); copy($lfile,$tmpleft); copy($rfile,$tmpright);
exec("exiftool -overwrite_original -n -Orientation=".$left[2]." ".$tmpleft."; exiftool -overwrite_original -n -Orientation=".$right[2]." ".$tmpright."; "); exec("exiftool -overwrite_original -n -Orientation=".$left[2]." ".$tmpleft."; exiftool -overwrite_original -n -Orientation=".$right[2]." ".$tmpright."; ");
exec("montage -label '%f' -font Helvetica -pointsize 20 -background '#000000' -fill 'white' -define jpeg:size=1000x1000 -geometry 1000x1000+2+2 -auto-orient ".$tmpleft." ".$tmpright." /tmp/contact_sheet_".$key.".jpg"); exec("montage -label '%f' -font Helvetica -pointsize 20 -background '#000000' -fill 'white' -define jpeg:size=1000x1000 -geometry 1000x1000+2+2 -auto-orient ".$tmpleft." ".$tmpright." /tmp/contact_sheet_".$key.".jpg");
$sheets[] = "/tmp/contact_sheet_".$key.".jpg"; $sheets[] = $tmpdir."contact_sheet_".$key.".jpg";
echo "."; echo ".";
} }
echo "\n\n"; echo "\n\n";