0.7.1
This commit is contained in:
81
leaf.php
81
leaf.php
@@ -2,7 +2,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Leaf - Tools for Book Scans
|
// Leaf - Tools for Book Scans
|
||||||
$version = "0.7.0";
|
$version = "0.7.1";
|
||||||
$time_start = microtime(true);
|
$time_start = microtime(true);
|
||||||
date_default_timezone_set("America/Los_Angeles");
|
date_default_timezone_set("America/Los_Angeles");
|
||||||
$xt = 3; // threads
|
$xt = 3; // threads
|
||||||
@@ -57,7 +57,7 @@ function fin($print = null) {
|
|||||||
if (isset($print)) {
|
if (isset($print)) {
|
||||||
echo "\n".$print;
|
echo "\n".$print;
|
||||||
}
|
}
|
||||||
echo "\nFinished in ".floor($time = microtime(true)-$_SERVER["REQUEST_TIME_FLOAT"])." seconds\n";
|
echo "\nFinished in ".floor($time = microtime(true)-$_SERVER["REQUEST_TIME_FLOAT"])." seconds\n\n";
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,10 +159,12 @@ deskew detect rotation angles
|
|||||||
-pad=<num> pixels to pad around crop area, default 80
|
-pad=<num> pixels to pad around crop area, default 80
|
||||||
-contrast=<num> contrast boost, default 20
|
-contrast=<num> contrast boost, default 20
|
||||||
-size=<num> size in pixels of dmap, default 2200
|
-size=<num> size in pixels of dmap, default 2200
|
||||||
|
-nomap don't use dmaps
|
||||||
divide wrapper for imagemagick Divide_Src
|
divide wrapper for imagemagick Divide_Src
|
||||||
-map=<file> specify brightness file
|
-map=<file> specify brightness file
|
||||||
-adjust=<params> levels adjustment (ex. \"0%,98%,.9\")
|
-adjust=<params> levels adjustment (ex. \"0%,98%,.9\")
|
||||||
-q=<quality> quality out of 100
|
-q=<quality> quality out of 100
|
||||||
|
-pages map file is for LR rotated pages
|
||||||
dupes Find duplicate images using computed PHASH on thumbnails
|
dupes Find duplicate images using computed PHASH on thumbnails
|
||||||
-threshold=<num> match threshold
|
-threshold=<num> match threshold
|
||||||
-walk=<num> comparison scope (compare n image to n, n+1, n+2, etc)
|
-walk=<num> comparison scope (compare n image to n, n+1, n+2, etc)
|
||||||
@@ -187,6 +189,49 @@ strip strip exif crop values from images with exiftool
|
|||||||
echo $help;
|
echo $help;
|
||||||
fin();
|
fin();
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Note: Generate
|
||||||
|
//////////////////////
|
||||||
|
} elseif (args("app") == "generate") {
|
||||||
|
echo Welcome("Generate final jpg images");
|
||||||
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
$files = glob(args("dir")."*.{jpg,JPG}", GLOB_BRACE);
|
||||||
|
|
||||||
|
echo "Checking EXIF values: ";
|
||||||
|
|
||||||
|
foreach ($files as $file) {
|
||||||
|
echo ".";
|
||||||
|
$lines = shell_exec("exiftool -s -s -s -f -Label -ConvertToGrayscale ".$file);
|
||||||
|
$parts = explode("\n", $lines);
|
||||||
|
if ($parts[0] == "bitmap") {
|
||||||
|
$bitmap[] = $file;
|
||||||
|
} elseif ($parts[1] == "True") {
|
||||||
|
$grey[] = $file;
|
||||||
|
} else {
|
||||||
|
$color[] = $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "\n\n";
|
||||||
|
|
||||||
|
echo "Bitmap files: ";
|
||||||
|
if (is_array($bitmap)) { echo count($bitmap); } else { echo "None"; }
|
||||||
|
|
||||||
|
echo "\n\n";
|
||||||
|
|
||||||
|
echo "Greyscale files: ";
|
||||||
|
if (is_array($grey)) { echo count($grey); } else { echo "None"; }
|
||||||
|
|
||||||
|
echo "\n\n";
|
||||||
|
|
||||||
|
echo "Color files: ";
|
||||||
|
if (is_array($color)) { echo count($color); } else { echo "None"; }
|
||||||
|
|
||||||
|
echo "\n\n";
|
||||||
|
|
||||||
|
fin();
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Note: Clean
|
// Note: Clean
|
||||||
//////////////////////
|
//////////////////////
|
||||||
@@ -748,6 +793,12 @@ echo Welcome("Composite image from brightness map");
|
|||||||
|
|
||||||
$files = glob(args("dir")."*.{jpg,JPG,tif}", GLOB_BRACE);
|
$files = glob(args("dir")."*.{jpg,JPG,tif}", GLOB_BRACE);
|
||||||
|
|
||||||
|
if (args("pages")) {
|
||||||
|
$pages = true;
|
||||||
|
} else {
|
||||||
|
$pages = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!args("map")) {
|
if (!args("map")) {
|
||||||
msg("No brightness map specified",1);
|
msg("No brightness map specified",1);
|
||||||
} elseif (!file_exists(args("map"))) {
|
} elseif (!file_exists(args("map"))) {
|
||||||
@@ -777,6 +828,8 @@ if (args("q")) {
|
|||||||
$quality = 95;
|
$quality = 95;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo "Building threads: ";
|
||||||
|
|
||||||
$thread = array();
|
$thread = array();
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
$msg = "Dividing ".$file." with ".$map.", Q=".$quality;
|
$msg = "Dividing ".$file." with ".$map.", Q=".$quality;
|
||||||
@@ -794,8 +847,24 @@ foreach ($files as $file) {
|
|||||||
} else {
|
} else {
|
||||||
$cmd = "convert ".$file." ".$tmap." -compose Divide_Src -composite -quality ".$quality." ".$dest."/".basename($file);
|
$cmd = "convert ".$file." ".$tmap." -compose Divide_Src -composite -quality ".$quality." ".$dest."/".basename($file);
|
||||||
}
|
}
|
||||||
|
if ($pages) {
|
||||||
|
$label = trim(shell_exec("exiftool -s -s -s -Label ".$file));
|
||||||
|
if ($label == "non-page") {
|
||||||
|
$msg .= "<Skipping non-page>";
|
||||||
|
$cmd = "true";
|
||||||
|
echo "o";
|
||||||
|
} else {
|
||||||
|
echo ".";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo ".";
|
||||||
|
}
|
||||||
|
$cmd = "true";
|
||||||
$thread[] = array($msg, $cmd);
|
$thread[] = array($msg, $cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo "\n\n";
|
||||||
|
|
||||||
msg("Beginning multithreaded convert with ".$xt." threads");
|
msg("Beginning multithreaded convert with ".$xt." threads");
|
||||||
multiexec($thread,$xt);
|
multiexec($thread,$xt);
|
||||||
|
|
||||||
@@ -1029,7 +1098,7 @@ foreach ($files as $file) {
|
|||||||
|
|
||||||
$thread = null;
|
$thread = null;
|
||||||
|
|
||||||
echo "\n\n";
|
echo "\n";
|
||||||
|
|
||||||
echo "Checking for existing rotation: ";
|
echo "Checking for existing rotation: ";
|
||||||
|
|
||||||
@@ -1062,17 +1131,19 @@ foreach ($files as $file) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "\n";
|
echo "\n\n";
|
||||||
|
|
||||||
msg("Write to EXIF?",2);
|
msg("Write to EXIF?",2);
|
||||||
|
|
||||||
if (is_array($thread)) {
|
if (is_array($thread)) {
|
||||||
|
|
||||||
msg("Writing EXIF tags with ".$xt." threads");
|
msg("Writing EXIF tags with ".$xt." threads");
|
||||||
//multiexec($thread,$xt);
|
multiexec($thread,$xt);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fin();
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Elif
|
// Elif
|
||||||
//////////////////////
|
//////////////////////
|
||||||
|
|||||||
Reference in New Issue
Block a user