diff --git a/leaf.php b/leaf.php index d84e384..3397ba1 100644 --- a/leaf.php +++ b/leaf.php @@ -343,7 +343,7 @@ foreach ($picks as $file) { $parts = chop(shell_exec("exiftool -s -s -s -XMP-crs:CropTop -XMP-crs:CropRight -XMP-crs:CropLeft -XMP-crs:CropBottom ".$file." 2>&1")); @list($top, $right, $left, $bottom) = explode("\n", $parts); if ($top && $right && $left && $bottom) { - $key = filter_var(substr(basename($file), 4), FILTER_SANITIZE_NUMBER_INT); + $key = abs(filter_var(substr(basename($file), 4), FILTER_SANITIZE_NUMBER_INT)); $crops[$key]['top'] = $top; $crops[$key]['right'] = $right; $crops[$key]['left'] = $left; @@ -513,7 +513,7 @@ echo Welcome("Display brightness values for a directory of images"); $files = glob(args("dir")."*.*"); foreach ($files as $file) { - echo $file.": ".filter_var(shell_exec("convert ".$file." -colorspace Gray -format \"%[fx:quantumrange*image.mean]\" info:"),FILTER_SANITIZE_NUMBER_INT)."\n"; + echo $file.": ".abs(filter_var(shell_exec("convert ".$file." -colorspace Gray -format \"%[fx:quantumrange*image.mean]\" info:"),FILTER_SANITIZE_NUMBER_INT))."\n"; } fin(); @@ -1171,7 +1171,7 @@ if (args("m")) { } else { $mid = $files[ceil(count($files)/2)]; echo "Guessing midpoint key from ".$mid."\n"; - $midpoint_key = filter_var($mid, FILTER_SANITIZE_NUMBER_INT); + $midpoint_key = abs(filter_var($mid, FILTER_SANITIZE_NUMBER_INT)); } $e = 2; $o = 1; @@ -1300,7 +1300,7 @@ $files = glob(args("dir")."*.*"); if ($multicrops > 1) { foreach ($files as $file) { - $key = filter_var(substr(basename($file), 4), FILTER_SANITIZE_NUMBER_INT); + $key = abs(filter_var(substr(basename($file), 4), FILTER_SANITIZE_NUMBER_INT)); $seq[$key] = $file; } ksort($seq); @@ -1332,7 +1332,7 @@ foreach ($picks as $file) { $parts = chop(shell_exec("exiftool -s -s -s -XMP-crs:CropTop -XMP-crs:CropRight -XMP-crs:CropLeft -XMP-crs:CropBottom ".$file." 2>&1")); @list($top, $right, $left, $bottom) = explode("\n", $parts); if ($top && $right && $left && $bottom) { - $key = filter_var(substr(basename($file), 4), FILTER_SANITIZE_NUMBER_INT); + $key = abs(filter_var(substr(basename($file), 4), FILTER_SANITIZE_NUMBER_INT)); $crops[$key]['top'] = $top; $crops[$key]['right'] = $right; $crops[$key]['left'] = $left; @@ -1354,7 +1354,7 @@ foreach ($crops as $key => $parts) { ask(""); echo "Crop Mapping:\n"; foreach ($files as $file) { - $key = filter_var(substr(basename($file), 4), FILTER_SANITIZE_NUMBER_INT); + $key = abs(filter_var(substr(basename($file), 4), FILTER_SANITIZE_NUMBER_INT)); $closekey = getClosest($key, array_keys($crops)); $parts = $crops[$closekey]; echo "\n"; @@ -1413,8 +1413,8 @@ echo "Comparing phash values: "; foreach ($tnfiles as $file) { foreach ($tnfiles as $nfile) { - $anum = filter_var($file, FILTER_SANITIZE_NUMBER_INT); - $bnum = filter_var($nfile, FILTER_SANITIZE_NUMBER_INT); + $anum = abs(filter_var($file, FILTER_SANITIZE_NUMBER_INT)); + $bnum = abs(filter_var($nfile, FILTER_SANITIZE_NUMBER_INT)); $diff = abs($anum-$bnum); $done[$file][$nfile] = 1; if ($file != $nfile && $diff < $walk && isset($done[$nfile][$file])) {