This commit is contained in:
2019-05-07 01:51:24 -07:00
parent 5f9e59d87c
commit 23300d6ae7

View File

@@ -2,7 +2,7 @@
<?php
// Leaf - Tools for Book Scans
$version = "0.6.0";
$version = "0.6.1";
$time_start = microtime(true);
// Functions
@@ -173,22 +173,32 @@ echo Welcome("Batch set EXIF resolution tags");
/////////////////////////////////////////////////////////////////////////
$files = glob(args("dir")."*.*");
if (null !== args("x")) {
if (args("height")) {
$height = args("height");
} elseif (args("x")) {
$x = args("x");
} else {
msg("No resolution value",1);
}
foreach ($files as $file) {
echo "Processing ".$file;
echo "Processing ".$file.": ";
$ext = pathinfo($file, PATHINFO_EXTENSION);
if ($height) {
list ($imwidth, $imheight) = getimagesize($file);
$x = floor($imheight/$height);
}
if ($ext == "jpg" | $ext == "JPG") {
exec("exiftool -overwrite_original -Xresolution=".$x." -Yresolution=".$x." ".$file);
exec("exiftool -overwrite_original -Xresolution=".$x." -Yresolution=".$x." -jfif:Xresolution=".$x." -jfif:Yresolution=".$x." ".$file);
echo "set DPI to ".$x;
} elseif ($ext == "DNG") {
exec("exiftool -overwrite_original -Xresolution=".$x." -Yresolution=".$x." -SubIFD:Xresolution=".$x." -SubIFD:Yresolution=".$x." -SubIFD1:Xresolution=".$x." -SubIFD1:Yresolution=".$x." ".$file);
echo "set DPI to ".$x;
} elseif ($ext == "png") {
$res = $x*39.37007874016;
exec("exiftool -overwrite_original -PixelsPerUnitX=".$res." -PixelsPerUnitY=".$res." ".$file);
echo "set DPI to ".$res;
} else {
echo " -> skip";
}