From 1eabc36369de608b06bff963250fd69ad357bf5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Wed, 19 Sep 2018 23:11:02 +0200 Subject: [PATCH] dot-issue solved --- .../usr/lib/cups/filter/pstoricohddst-gdi | 170 ++++++++---------- 1 file changed, 76 insertions(+), 94 deletions(-) diff --git a/ricoh-sp100/usr/lib/cups/filter/pstoricohddst-gdi b/ricoh-sp100/usr/lib/cups/filter/pstoricohddst-gdi index f86f9b6..71d0f8d 100755 --- a/ricoh-sp100/usr/lib/cups/filter/pstoricohddst-gdi +++ b/ricoh-sp100/usr/lib/cups/filter/pstoricohddst-gdi @@ -1,7 +1,7 @@ #!/bin/bash # Debug mode: change to 'yes' to enable -DEBUG=no +DEBUG=${DEBUG-no} function log() { [ "${DEBUG}" = "yes" ] && echo $* | logger -t "$0[$$]" @@ -23,6 +23,72 @@ function stop() { echo "stop" > $uid/999999999-page.pbm } +function output_page() { + # Converting page to JBIG format (parameters are very special for this printer!) + pbmtojbg -p 72 -o 3 -m 0 -q < $page > $uid/raster.jbig + + # Taking image size + jsize=`wc -c < $uid/raster.jbig` + + # Taking image dimensions + x=($(identify -format "%w %h %[fx:mean] " $page)) + ## + # The %[fx:mean] gives the average colour in the image which for + # monochrome is the number of white pixels divided by the size + # + # So the formula gives the number of black pixels. The final + # /1 causes bc to round to the nearest integer because scale=0 + ## + dots=$(echo "(${x[0]}*${x[1]}*(1-${x[2]}))/1"|bc) + ## + # FIX: toner cartridge runs out way too fast with this dots + # calculation above and once it decides it's empty, you + # can't force it to print. So set dots to an artificially + # low number + dots=$(echo "$dots/10"|bc) + + # Flushing page header + cat < $uid/raster.jbig - - # Taking image size - jsize=`wc -c < $uid/raster.jbig` - - # Taking image dimensions - read fn ft xs ys garb < <(identify $uid/$page | tr "x" " ") - - # Flushing page header - cat < $uid/raster.jbig - - # Taking image size - jsize=`wc -c < $uid/raster.jbig` - - # Taking image dimensions - read fn ft xs ys garb < <(identify $page | tr "x" " ") - log "Identified as ${xs}x${ys}" - - # Flushing page header - cat <