This commit is contained in:
2019-11-07 15:00:44 -08:00
parent 42606ddcf6
commit 4cf9c656d5
2 changed files with 14 additions and 12 deletions

View File

@@ -2,6 +2,7 @@
- Option to mix levels adjustment with original
- Removed "a" flag from trash command
- Tweak to PNG dimensions
[0.9.0.1]

View File

@@ -154,7 +154,7 @@ function fin($print = null) {
if (isset($print)) {
echo "\n".$print;
}
$finished = "\nFinished in ".floor($time = microtime(true)-$_SERVER["REQUEST_TIME_FLOAT"])." seconds\n\n";
$finished = "\nFinished in ".round($time = microtime(true)-$_SERVER["REQUEST_TIME_FLOAT"])." seconds\n\n";
file_put_contents("leaf.log",$finished,FILE_APPEND);
die;
}
@@ -806,28 +806,29 @@ $ratioavg = number_format(array_sum($dims)/count($dims),3);
echo "Average page ratio: ".$ratioavg;
if ($ratioavg > 1) { // page is tall
$page_height = $pixels;
$page_width = floor($page_height/$ratioavg);
$page_width = round($page_height/$ratioavg);
$paper_height = $inches;
$paper_width = number_format($paper_height/$ratioavg,2);
} else {
$page_width = $pixels;
$page_height = floor($page_width*$ratioavg);
$page_height = round($page_width*$ratioavg);
$paper_width = $inches;
$paper_height = number_format($paper_width*$ratioavg,2);
}
$dpi = number_format($page_height/$paper_height,2);
$canonicalpngdpi = number_format($dpi*$multiplier,2);
$pngdpi = $canonicalpngdpi*39.37007874016;
$dpi = round($page_height/$paper_height,3);
$canonicalpngdpi = round($dpi)*$multiplier;
$pngdpi = round($canonicalpngdpi*39.37007874016);
$dims = $page_width."x".$page_height;
$pngdims = ($page_width*$multiplier)."x".($page_height*$multiplier);
// png dpi does not accept decimal points, so we will adjust the png dims slightly to better match jpg size
$pngdims = (round($canonicalpngdpi*$paper_width))."x".(round($canonicalpngdpi*$paper_height));
echo "\n";
echo "Page size: ".$paper_width."\" x ".$paper_height."\"";
echo "\n";
echo "Target pixel dimensions: ".$dims." (png=".$pngdims.")";
echo "\n";
echo "DPI = ".$dpi." (png=".$canonicalpngdpi.")";
echo "DPI = ".$dpi." (png=".$pngdpi.")";
foreach ($color as $parts) {
$jpg[] = $parts;
@@ -893,7 +894,7 @@ foreach ($jpg as $parts) {
$levelcmd .= "-modulate ".args("modulate")." ";
}
if (args("mix") && $levelcmd) {
if (args("mix") && $levelcmd && $iscolor) {
// if this is a mix, we reset the $cmd so we can nest the levels command and mix with og
$msg .= " <MIX=".args("mix").">";
$cmd = "convert \( ".$file." -resize ".$dims."\! ".$levelcmd."\) \( ".$file." -resize ".$dims."\! \) -define compose:args=".args("mix")." -compose blend -composite ";
@@ -909,7 +910,7 @@ foreach ($jpg as $parts) {
$msg .= " [Q=".$quality."]";
$cmd .= "-quality ".$quality." ";
if (args("mix") && $levelcmd) {
if (args("mix") && $levelcmd && $iscolor) {
$cmd .= $output;
} else {
$cmd .= $file." ".$output;
@@ -1588,7 +1589,7 @@ foreach ($files as $file) {
}
$print[] = bashcolor($attr['Image Width']."x".$attr['Image Height'], $color);
if (isset($attr['X Resolution'])) {
$print[] = bashcolor(floor($attr['X Resolution']).":".floor($attr['Y Resolution']), "brown");
$print[] = bashcolor(round($attr['X Resolution']).":".round($attr['Y Resolution']), "brown");
$width = number_format($attr['Image Width']/$attr['X Resolution'],2);
$height = number_format($attr['Image Height']/$attr['Y Resolution'],2);
$print[] = bashcolor($width."\" x ".$height."\"", "white", "black");
@@ -1836,7 +1837,7 @@ foreach ($files as $file) {
$ext = pathinfo($file, PATHINFO_EXTENSION);
if (isset($height)) {
list ($imwidth, $imheight) = getimagesize($file);
$x = floor($imheight/$height);
$x = round($imheight/$height);
}
if ($ext == "jpg" || $ext == "JPG") {
exec("exiftool -overwrite_original -Xresolution=".$x." -Yresolution=".$x." -jfif:Xresolution=".$x." -jfif:Yresolution=".$x." ".$file);