blank page detection nach dem scannen
Florian Lohoff
flo at rfc822.org
Wed Apr 8 13:04:24 CEST 2009
On Wed, Apr 08, 2009 at 12:17:04PM +0200, Florian Lohoff wrote:
> TMPDIR=$1
>
> unpaper=/usr/bin/unpaper
> pnmtotiff=/usr/bin/pnmtotiff
> tiffcp=/usr/bin/tiffcp
> tiff2pdf=/usr/bin/tiff2pdf
>
> set -x
>
> OUTPUT=~/Desktop/scan-`date +%Y%m%d%H%M%S`.pdf
>
> ${unpaper} -v --layout none ${TMPDIR}/scan-%d.pnm ${TMPDIR}/unpaper-%d.pnm
>
> for file in ${TMPDIR}/unpaper*; do
> ${pnmtotiff} $file >$file.tiff
> done
>
> ${tiffcp} ${TMPDIR}/*.tiff ${TMPDIR}/allpages.tiff
>
> ${tiff2pdf} -z -o ${OUTPUT} ${TMPDIR}/allpages.tiff
>
> Der naechste schritt waere noch via tesseract ein OCR und das
> als comment ans PDF haengen - aber das beim naechsten mal.
>
> Jetzt erstmal - Wie werde ich "leere" seiten los?
Okay - die 20kbyte scheinen ganz gut - so loese ich das jetzt und
bisher klappts gut ...
#!/bin/sh
TMPDIR=$1
blankpagesize=20k
unpaper=/usr/bin/unpaper
pnmtojpeg=/usr/bin/pnmtojpeg
pnmtotiff=/usr/bin/pnmtotiff
tiffcp=/usr/bin/tiffcp
tiff2pdf=/usr/bin/tiff2pdf
pnmtopng=/usr/bin/pnmtopng
set -x
OUTPUT=~/Desktop/scan-`date +%Y%m%d%H%M%S`.pdf
${unpaper} -v --layout none ${TMPDIR}/scan-%d.pnm ${TMPDIR}/unpaper-%d.pnm
for file in ${TMPDIR}/unpaper*; do
${pnmtotiff} $file >$file.tiff.uncompress
${tiffcp} -c zip:2 $file.tiff.uncompress $file.tiff
done
files=`find ${TMPDIR} -iname "unpaper*tiff" -size +$blankpagesize`
${tiffcp} ${files} ${TMPDIR}/allpages.tiff
${tiff2pdf} -z -o ${OUTPUT} ${TMPDIR}/allpages.tiff
ls -la ${TMPDIR}
Flo
--
Florian Lohoff flo at rfc822.org +49-171-2280134
Those who would give up a little freedom to get a little
security shall soon have neither - Benjamin Franklin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lug-owl.de/pipermail/linux/attachments/20090408/30e97104/attachment.sig>
More information about the Linux
mailing list