diff --git a/leaf.php b/leaf.php index 60bb08f..4922c49 100644 --- a/leaf.php +++ b/leaf.php @@ -2,7 +2,7 @@ pixels to pad around crop area, default 80 -contrast= contrast boost, default 20 -size= size in pixels of dmap, default 2200 + -nomap don't use dmaps divide wrapper for imagemagick Divide_Src -map= specify brightness file -adjust= levels adjustment (ex. \"0%,98%,.9\") -q= quality out of 100 + -pages map file is for LR rotated pages dupes Find duplicate images using computed PHASH on thumbnails -threshold= match threshold -walk= 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; 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 ////////////////////// @@ -748,6 +793,12 @@ echo Welcome("Composite image from brightness map"); $files = glob(args("dir")."*.{jpg,JPG,tif}", GLOB_BRACE); +if (args("pages")) { + $pages = true; + } else { + $pages = false; + } + if (!args("map")) { msg("No brightness map specified",1); } elseif (!file_exists(args("map"))) { @@ -777,6 +828,8 @@ if (args("q")) { $quality = 95; } +echo "Building threads: "; + $thread = array(); foreach ($files as $file) { $msg = "Dividing ".$file." with ".$map.", Q=".$quality; @@ -789,13 +842,29 @@ foreach ($files as $file) { $tmap = $map; } if (args("adjust")) { - $msg .= " (".args("adjust").")"; + $msg .= " (".args("adjust").") "; $cmd = "convert ".$file." ".$tmap." -compose Divide_Src -composite -level ".args("adjust")." -quality ".$quality." ".$dest."/".basename($file); } else { $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 .= ""; + $cmd = "true"; + echo "o"; + } else { + echo "."; + } + } else { + echo "."; + } + $cmd = "true"; $thread[] = array($msg, $cmd); } + +echo "\n\n"; + msg("Beginning multithreaded convert with ".$xt." threads"); multiexec($thread,$xt); @@ -1029,7 +1098,7 @@ foreach ($files as $file) { $thread = null; -echo "\n\n"; +echo "\n"; echo "Checking for existing rotation: "; @@ -1062,17 +1131,19 @@ foreach ($files as $file) { } -echo "\n"; +echo "\n\n"; msg("Write to EXIF?",2); if (is_array($thread)) { msg("Writing EXIF tags with ".$xt." threads"); - //multiexec($thread,$xt); + multiexec($thread,$xt); } +fin(); + //////////////////////////////////////////////////////////////////////////////////////////////// // Elif //////////////////////