Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.misc > #95654 > unrolled thread
| Started by | Charlie Gibbs <cgibbs@kltpzyxm.invalid> |
|---|---|
| First post | 2026-11-15 00:56 +0000 |
| Last post | 2026-11-17 07:25 +1000 |
| Articles | 16 on this page of 36 — 14 participants |
Back to article view | Back to comp.os.linux.misc
Shrinking huge PDF files Charlie Gibbs <cgibbs@kltpzyxm.invalid> - 2026-11-15 00:56 +0000
Re: Shrinking huge PDF files "Carlos E.R." <robin_listas@es.invalid> - 2026-11-15 02:16 +0100
Re: Shrinking huge PDF files Nuno Silva <nunojsilva@invalid.invalid> - 2026-11-15 10:40 +0000
Re: Shrinking huge PDF files "Carlos E.R." <robin_listas@es.invalid> - 2026-11-15 13:29 +0100
Re: Shrinking huge PDF files Nuno Silva <nunojsilva@invalid.invalid> - 2026-11-15 01:28 +0000
Re: Shrinking huge PDF files Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-11-15 01:49 +0000
Re: Shrinking huge PDF files 🇵🇱Jacek Marcin Jaworski🇵🇱 <jmj@energokod.gda.pl> - 2026-11-15 03:26 +0100
Re: Shrinking huge PDF files Rich <rich@example.invalid> - 2026-11-15 03:16 +0000
Re: Shrinking huge PDF files Andreas Eder <a_eder_muc@web.de> - 2026-11-15 10:50 +0100
Re: Shrinking huge PDF files Russell Marks <zgedneil@spam^H^H^H^Hgmail.com> - 2026-11-15 10:18 +0000
Re: Shrinking huge PDF files Charlie Gibbs <cgibbs@kltpzyxm.invalid> - 2026-11-15 23:31 +0000
Re: Shrinking huge PDF files c186282 <c186282@nnada.net> - 2026-11-15 22:16 -0500
Re: Shrinking huge PDF files Charlie Gibbs <cgibbs@kltpzyxm.invalid> - 2026-11-16 05:04 +0000
Re: Shrinking huge PDF files Mike Scott <usenet.16@scottsonline.org.uk.invalid> - 2026-11-16 07:09 +0000
Re: Shrinking huge PDF files Charlie Gibbs <cgibbs@kltpzyxm.invalid> - 2026-11-16 17:02 +0000
Re: Shrinking huge PDF files The Natural Philosopher <tnp@invalid.invalid> - 2026-11-16 18:17 +0000
Re: Shrinking huge PDF files Rich <rich@example.invalid> - 2026-11-16 18:55 +0000
Re: Shrinking huge PDF files c186282 <c186282@nnada.net> - 2026-11-16 21:29 -0500
Re: Shrinking huge PDF files Nuno Silva <nunojsilva@invalid.invalid> - 2026-11-22 11:00 +0000
Re: Shrinking huge PDF files "Carlos E.R." <robin_listas@es.invalid> - 2026-11-16 09:47 +0100
Re: Shrinking huge PDF files Nuno Silva <nunojsilva@invalid.invalid> - 2026-11-16 08:56 +0000
djvu [Was: Re: Shrinking huge PDF files] "Carlos E.R." <robin_listas@es.invalid> - 2026-11-16 11:15 +0100
Re: djvu [Was: Re: Shrinking huge PDF files] Andy Burns <usenet@andyburns.uk> - 2026-11-16 13:18 +0000
Re: djvu [Was: Re: Shrinking huge PDF files] Rich <rich@example.invalid> - 2026-11-16 19:00 +0000
Re: djvu [Was: Re: Shrinking huge PDF files] Nuno Silva <nunojsilva@invalid.invalid> - 2026-11-23 00:13 +0000
Re: djvu [Was: Re: Shrinking huge PDF files] "Carlos E.R." <robin_listas@es.invalid> - 2026-11-23 01:54 +0100
Re: djvu [Was: Re: Shrinking huge PDF files] Andy Burns <usenet@andyburns.uk> - 2026-11-23 06:35 +0000
Re: djvu [Was: Re: Shrinking huge PDF files] "Carlos E.R." <robin_listas@es.invalid> - 2026-11-17 03:00 +0100
Re: djvu [Was: Re: Shrinking huge PDF files] Rich <rich@example.invalid> - 2026-11-16 18:59 +0000
Re: Shrinking huge PDF files Charlie Gibbs <cgibbs@kltpzyxm.invalid> - 2026-11-16 17:02 +0000
Re: Shrinking huge PDF files Rich <rich@example.invalid> - 2026-11-16 19:01 +0000
Re: Shrinking huge PDF files Charlie Gibbs <cgibbs@kltpzyxm.invalid> - 2026-11-16 19:20 +0000
Re: Shrinking huge PDF files Leroy H <lh@somewhere.net> - 2026-11-16 20:03 +0000
Re: Shrinking huge PDF files Rich <rich@example.invalid> - 2026-11-16 22:04 +0000
Re: Shrinking huge PDF files Charlie Gibbs <cgibbs@kltpzyxm.invalid> - 2026-11-17 02:00 +0000
Re: Shrinking huge PDF files not@telling.you.invalid (Computer Nerd Kev) - 2026-11-17 07:25 +1000
Page 2 of 2 — ← Prev page 1 [2]
| From | Nuno Silva <nunojsilva@invalid.invalid> |
|---|---|
| Date | 2026-11-16 08:56 +0000 |
| Message-ID | <11degfs$3d3uk$2@dont-email.me> |
| In reply to | #95696 |
On 2026-11-15, Charlie Gibbs wrote:
> Thanks, everyone, for your suggestions. Here's a history of my
> various attempts. To keep things simple, I extracted the first
> page of the 11-page original file (32,468,435 bytes) as follows:
>
> $ pdftk hugefile.pdf cat 1 output testfile.pdf
>
> This resulted in a file of 1,520,696 bytes; the reduction in size is
> a lot more than 11 to 1, so pdftk must be doing some magic of its own.
>
> $ pdfimages -list testfile.pdf
> page num type width height color comp bpc enc interp object ID x-ppi y-ppi size ratio
> --------------------------------------------------------------------------------------------
> 1 0 image 1928 2754 icc 3 8 jpeg yes 6 0 72 72 1481K 9.5%
>
> This indicates colour (icc) with three 8-bit components per pixel.
>
> $ identify testfile.pdf
> testfile.pdf PDF 1944x2772 1944x2772+0+0 16-bit sRGB 9615B 0.010u 0:00.000
>
> Now let's have GhostScript convert the file to grayscale,
> using a suggestion from Nuno Silva:
>
> $ gs -sDEVICE=pdfwrite -sColorConversionStrategy=Gray \
> -sProcessColorModel=DeviceGray -sOutputFile=testfile2.pdf testfile.pdf
>
> This converted the file to grayscale (8 bits per pixel, still with
> JPEG compression; its size is now 359,415 bytes.
>
> Following the URL given by Lawrence D'Oliveiro
> <https://ghostscript.readthedocs.io/gs10.08.0/Devices.html>
> gave a bewildering array of possibilities (the GhostScript
> command "devicenames ==" is even more intimidating).
> Changing the device from pdfwrite to pngmono got the size down
> to 112,386 bytes. The ImageMagick utility "identify" says it's
> 8-bit grayscale.
>
> We're getting the file size down to something more reasonable.
> However, contrast isn't all that good. Let's see whether we
> can go for monochrome.
>
> Working with Rich's suggestions, I ran the following:
> $ gs -sDEVICE=pgmraw -sColorConversionStrategy=Gray \
> -sProcessColorModel=DeviceGray -sOutputFile=testfile3.pgm testfile.pdf
> $ pgmtopbm -threshold -value 0.82 testfile3.pgm | pnmtotiff -g4 >testfile3.tif
> $ tiff2pdf -o testfile3.pdf testfile3.tif
>
> Bingo! I wound up with a crisp PDF file whose size is only 48,071
> bytes: a 30-to-1 reduction. This size is typical of what I get
> when I do my own scanning. And by tweaking the threshold value
> from 0.82 to 0.9 I was able to bring out penciled notes without
> getting black blotches everywhere.
>
> Adding the capability to handle multi-page documents uncovered a
> few problems. The sizes of the images seem to vary from page to
> page, and some some pages have shadows that make it difficult to
> make pencil marks visible without getting those big black blotches
> I mentioned earlier. If I could persuade the person doing the
> scanning to be careful to avoid shadows, my final script should
> be able to do a wonderful job of cleaning up such files. This
> might not be an option, though - most people seem unable or
> unwilling to take the necessary care. At least the images
> aren't keystoned...
>
> Thanks, everyone, for your help!
Consider having a look at ImageMagick's convert with -lat, "local
adaptive thresholding". Sadly, my notes don't go beyond saying it's
better than just threshold... example command line:
convert in.pnm -lat 100x700-15% out.pbm
<https://usage.imagemagick.org/transform/#lat>
(unpaper might also be useful, depending on how the input documents
are?:)
<https://flameeyes.com/projects/unpaper>
(And if you end up converting the document to monochrome, it's probably
worth considering at least comparing with DjVu unless you need it to be
PDF.)
--
Nuno Silva
[toc] | [prev] | [next] | [standalone]
| From | "Carlos E.R." <robin_listas@es.invalid> |
|---|---|
| Date | 2026-11-16 11:15 +0100 |
| Subject | djvu [Was: Re: Shrinking huge PDF files] |
| Message-ID | <kn1rsmx5sd.ln2@Telcontar.valinor> |
| In reply to | #95708 |
On 2026-11-16 09:56, Nuno Silva wrote:
> (And if you end up converting the document to monochrome, it's probably
> worth considering at least comparing with DjVu unless you need it to be
> PDF.)
How do you handle conversion to djvu in Linux? I have found few people that use this format.
I use a script, that basically does this:
C44=c44
PNGTOPNM=pngtopnm
"image/jpeg") $C44 -dpi 240 -slice $SLICE -crcbhalf "$FILE"
"image/png")
$PNGTOPNM "$FILE" > "$NOMBRECMPLTO"pnm
$C44 -dpi $DPI -slice "23+19+17+13+9+7+5+3" -crcbhalf "$NOMBRECMPLTO"pnm
rm "$NOMBRECMPLTO"pnm
(I do some adjustments depending on DPI, but I removed for clarity)
I understand that there are better tools (payware) in Windows.
--
Cheers, Carlos.
ES🇪🇸, EU🇪🇺;
[toc] | [prev] | [next] | [standalone]
| From | Andy Burns <usenet@andyburns.uk> |
|---|---|
| Date | 2026-11-16 13:18 +0000 |
| Subject | Re: djvu [Was: Re: Shrinking huge PDF files] |
| Message-ID | <nm0e5rFu3teU1@mid.individual.net> |
| In reply to | #95710 |
"Carlos E.R." wrote: > How do you handle conversion to djvu in Linux? I have found few people > that use this format. I can see that at one time, DjVu would have had advantages over Pdf, is that still true, especially with Pdf/A ?
[toc] | [prev] | [next] | [standalone]
| From | Rich <rich@example.invalid> |
|---|---|
| Date | 2026-11-16 19:00 +0000 |
| Subject | Re: djvu [Was: Re: Shrinking huge PDF files] |
| Message-ID | <11dfjsr$3qfni$3@dont-email.me> |
| In reply to | #95714 |
Andy Burns <usenet@andyburns.uk> wrote: > "Carlos E.R." wrote: > >> How do you handle conversion to djvu in Linux? I have found few people >> that use this format. > > I can see that at one time, DjVu would have had advantages over Pdf, is > that still true, especially with Pdf/A ? For file size, and monochrome images, djvu will most often be much smaller than the same monochrome PDF. But as most others won't have a djvu reader installed, it is not a great "interchange" format unless you already know the receiver is capable of reading the file.
[toc] | [prev] | [next] | [standalone]
| From | Nuno Silva <nunojsilva@invalid.invalid> |
|---|---|
| Date | 2026-11-23 00:13 +0000 |
| Subject | Re: djvu [Was: Re: Shrinking huge PDF files] |
| Message-ID | <11e00el$1cu9b$5@dont-email.me> |
| In reply to | #95726 |
On 2026-11-16, Rich wrote: > Andy Burns <usenet@andyburns.uk> wrote: >> "Carlos E.R." wrote: >> >>> How do you handle conversion to djvu in Linux? I have found few people >>> that use this format. >> >> I can see that at one time, DjVu would have had advantages over Pdf, is >> that still true, especially with Pdf/A ? > > For file size, and monochrome images, djvu will most often be much > smaller than the same monochrome PDF. I'd argue they're not for the same purpose, I'd use DjVu for *scanned* documents and PDF for, well, "vectorial" documents, so to speak. And, at scanned ones, DjVu can indeed excel. Depends on the kind of input and on whether the tools can actually achieve a good compression for the input. Some commercial scanners encode scanned documents using layered images of differing qualities in PDF (or at least that's one of the approaches I've seen), and maybe when *that* is used you get more competitive small file sizes. > But as most others won't have a djvu reader installed, it is not a > great "interchange" format unless you already know the receiver is > capable of reading the file. Maybe we need a djvu.js counterpart to pdf.js :-D Thankfully, at least some of the standalone PDF viewers can also do DjVu. At one point, a convenient way to add one to Windows NT was to grab Evince. -- Nuno Silva
[toc] | [prev] | [next] | [standalone]
| From | "Carlos E.R." <robin_listas@es.invalid> |
|---|---|
| Date | 2026-11-23 01:54 +0100 |
| Subject | Re: djvu [Was: Re: Shrinking huge PDF files] |
| Message-ID | <uffctmx8mt.ln2@Telcontar.valinor> |
| In reply to | #95850 |
On 2026-11-23 01:13, Nuno Silva wrote: > On 2026-11-16, Rich wrote: > >> Andy Burns <usenet@andyburns.uk> wrote: >>> "Carlos E.R." wrote: >>> >>>> How do you handle conversion to djvu in Linux? I have found few people >>>> that use this format. >>> >>> I can see that at one time, DjVu would have had advantages over Pdf, is >>> that still true, especially with Pdf/A ? >> >> For file size, and monochrome images, djvu will most often be much >> smaller than the same monochrome PDF. > > > I'd argue they're not for the same purpose, I'd use DjVu for *scanned* > documents and PDF for, well, "vectorial" documents, so to speak. > > And, at scanned ones, DjVu can indeed excel. Depends on the kind of > input and on whether the tools can actually achieve a good compression > for the input. > > Some commercial scanners encode scanned documents using layered images > of differing qualities in PDF (or at least that's one of the approaches > I've seen), and maybe when *that* is used you get more competitive small > file sizes. > >> But as most others won't have a djvu reader installed, it is not a >> great "interchange" format unless you already know the receiver is >> capable of reading the file. > > Maybe we need a djvu.js counterpart to pdf.js :-D > > Thankfully, at least some of the standalone PDF viewers can also do > DjVu. At one point, a convenient way to add one to Windows NT was to > grab Evince. > One problem with DjVu is that, for instance, gimp doesn't support it. Neither does LibreOffice. I save scanned documents to both jpg and djvu, and djvu is often better. But then, can not put the photo in a LO document. Years ago, I knew that they had developed commercial DjVu creation softwre for Windows, automating the conversion to DjVu, supposedly choosing the best settings automatically. The Linux tools are "too manual". -- Cheers, Carlos. ES🇪🇸, EU🇪🇺;
[toc] | [prev] | [next] | [standalone]
| From | Andy Burns <usenet@andyburns.uk> |
|---|---|
| Date | 2026-11-23 06:35 +0000 |
| Subject | Re: djvu [Was: Re: Shrinking huge PDF files] |
| Message-ID | <nmi558Fu0r0U1@mid.individual.net> |
| In reply to | #95850 |
Nuno Silva wrote: > Maybe we need a djvu.js counterpart to pdf.js 😂 > Thankfully, at least some of the standalone PDF viewers can also do > DjVu. Thanks, I'd never realised that my chosen viewer (SumatraPDF) includes DjVu support.
[toc] | [prev] | [next] | [standalone]
| From | "Carlos E.R." <robin_listas@es.invalid> |
|---|---|
| Date | 2026-11-17 03:00 +0100 |
| Subject | Re: djvu [Was: Re: Shrinking huge PDF files] |
| Message-ID | <j2pssmx002.ln2@Telcontar.valinor> |
| In reply to | #95714 |
On 2026-11-16 14:18, Andy Burns wrote: > "Carlos E.R." wrote: > >> How do you handle conversion to djvu in Linux? I have found few people >> that use this format. > > I can see that at one time, DjVu would have had advantages over Pdf, is > that still true, especially with Pdf/A ? > I have not done recent checking, I don't know about Pdf/A. djvu compresses itself, so it is akin to jpeg in that respect. And it is a also a collection of pages, like PDF. And as a compressor, it does a better job than jpeg because its goal was scanned images from design day, so it works very well with those. -- Cheers, Carlos. ES🇪🇸, EU🇪🇺;
[toc] | [prev] | [next] | [standalone]
| From | Rich <rich@example.invalid> |
|---|---|
| Date | 2026-11-16 18:59 +0000 |
| Subject | Re: djvu [Was: Re: Shrinking huge PDF files] |
| Message-ID | <11dfjq1$3qfni$2@dont-email.me> |
| In reply to | #95710 |
Carlos E.R. <robin_listas@es.invalid> wrote: > On 2026-11-16 09:56, Nuno Silva wrote: >> (And if you end up converting the document to monochrome, it's probably >> worth considering at least comparing with DjVu unless you need it to be >> PDF.) > > How do you handle conversion to djvu in Linux? I have found few > people that use this format. Provided you have DJVULibre installed, it is the cjb2 executable. You do need to input monochrome pbm or tiff at the outset, cjb2 does not do any color conversions and will just abort with a non-monochrome input image. Options are -dpi # to tell it the dpi of the scan. -clean to clean up specks. And either -lossy or -losslevel # (I usually use 50 here) to tell it how much lossiness is tolerable. And, usually, djvu will be considerably smaller than G4 fax in a PDF. But it won't be a PDF and so most non-technical users simply won't be able to view it.
[toc] | [prev] | [next] | [standalone]
| From | Charlie Gibbs <cgibbs@kltpzyxm.invalid> |
|---|---|
| Date | 2026-11-16 17:02 +0000 |
| Message-ID | <vGGKS.129464$aI4.75531@fx15.iad> |
| In reply to | #95708 |
On 2026-11-16, Nuno Silva <nunojsilva@invalid.invalid> wrote: > Consider having a look at ImageMagick's convert with -lat, "local > adaptive thresholding". Sadly, my notes don't go beyond saying it's > better than just threshold... example command line: > > convert in.pnm -lat 100x700-15% out.pbm > > <https://usage.imagemagick.org/transform/#lat> That sounds interesting! I'll give it a look. > (unpaper might also be useful, depending on how the input documents > are?:) > > <https://flameeyes.com/projects/unpaper> > > (And if you end up converting the document to monochrome, it's probably > worth considering at least comparing with DjVu unless you need it to be > PDF.) I'm dealing with musicians here, not computer geeks. Going to some obscure new format would be just one more headache to deal with. -- /~\ Charlie Gibbs | In this world there are \ / <cgibbs@kltpzyxm.invalid> | two kinds of people: X I'm really at ac.dekanfrus | 1. Those who can extrapolate / \ if you read it the right way. | from incomplete data.
[toc] | [prev] | [next] | [standalone]
| From | Rich <rich@example.invalid> |
|---|---|
| Date | 2026-11-16 19:01 +0000 |
| Message-ID | <11dfjun$3qfni$4@dont-email.me> |
| In reply to | #95719 |
Charlie Gibbs <cgibbs@kltpzyxm.invalid> wrote: > I'm dealing with musicians here, not computer geeks. Going to some > obscure new format would be just one more headache to deal with. Then don't bother with anything other than PDF. That one they will be able to open and view. Anything else, yes, a headache for you.
[toc] | [prev] | [next] | [standalone]
| From | Charlie Gibbs <cgibbs@kltpzyxm.invalid> |
|---|---|
| Date | 2026-11-16 19:20 +0000 |
| Message-ID | <oIIKS.56667$033.46236@fx03.iad> |
| In reply to | #95727 |
On 2026-11-16, Rich <rich@example.invalid> wrote: > Charlie Gibbs <cgibbs@kltpzyxm.invalid> wrote: > >> I'm dealing with musicians here, not computer geeks. Going to some >> obscure new format would be just one more headache to deal with. > > Then don't bother with anything other than PDF. That one they will be > able to open and view. Anything else, yes, a headache for you. Indeed. Thanks for the help. Unfortunately, my tests have suddenly stopped working - pgmtopbm has seemingly started ignoring my threshold setting. Stripping down the commands to work on a single-page PDF: $ gs -dNOPAUSE -q -r300 -sDEVICE=pgmraw -dBATCH -sOutputFile=testfile3.pgm testfile.pdf $ pgmtopbm -threshold -value 0.82 testfile3.pgm >testfile3.pnm $ pnmtotiff -g4 <testfile3.pnm >testfile3.tif Is there something wrong with my pgmtopbm command? If I remove the "-threshold -value 0.82" parameters the output (testfile3.pnm) is exactly the same. -- /~\ Charlie Gibbs | In this world there are \ / <cgibbs@kltpzyxm.invalid> | two kinds of people: X I'm really at ac.dekanfrus | 1. Those who can extrapolate / \ if you read it the right way. | from incomplete data.
[toc] | [prev] | [next] | [standalone]
| From | Leroy H <lh@somewhere.net> |
|---|---|
| Date | 2026-11-16 20:03 +0000 |
| Message-ID | <18e89f20f2f0630b$3375$3325340$802601b3@news.usenetexpress.com> |
| In reply to | #95728 |
On Mon, 16 Nov 2026 19:20:52 GMT, Charlie Gibbs wrote: > > Indeed. Thanks for the help. Unfortunately, my tests have suddenly > stopped working > The advice given on this forum is crap. For the definitive guide to archival scanning consult my web page: <http://lapiet.info/gnulinux/scanning/archscan.html> For black/white or grayscale images the format to use is JBIG2.
[toc] | [prev] | [next] | [standalone]
| From | Rich <rich@example.invalid> |
|---|---|
| Date | 2026-11-16 22:04 +0000 |
| Message-ID | <11dfum7$3uejh$1@dont-email.me> |
| In reply to | #95728 |
Charlie Gibbs <cgibbs@kltpzyxm.invalid> wrote: > On 2026-11-16, Rich <rich@example.invalid> wrote: > >> Charlie Gibbs <cgibbs@kltpzyxm.invalid> wrote: >> >>> I'm dealing with musicians here, not computer geeks. Going to some >>> obscure new format would be just one more headache to deal with. >> >> Then don't bother with anything other than PDF. That one they will be >> able to open and view. Anything else, yes, a headache for you. > > Indeed. Thanks for the help. Unfortunately, my tests have suddenly > stopped working - pgmtopbm has seemingly started ignoring my threshold > setting. Stripping down the commands to work on a single-page PDF: > > $ gs -dNOPAUSE -q -r300 -sDEVICE=pgmraw -dBATCH -sOutputFile=testfile3.pgm testfile.pdf > $ pgmtopbm -threshold -value 0.82 testfile3.pgm >testfile3.pnm > $ pnmtotiff -g4 <testfile3.pnm >testfile3.tif > > Is there something wrong with my pgmtopbm command? Not that I see from the above example, other than the result file should be named ".pbm" as it is a Portable Bit Map (monochrome) file. But so long as you use the same name to feed into pnmtotiff it won't matter a bit what you name it. > If I remove the "-threshold -value 0.82" parameters > the output (testfile3.pnm) is exactly the same. Weird. I would expect some change, as it is supposed to be outputting pbm, and you should be sending in greyscale, so the two files should differ.
[toc] | [prev] | [next] | [standalone]
| From | Charlie Gibbs <cgibbs@kltpzyxm.invalid> |
|---|---|
| Date | 2026-11-17 02:00 +0000 |
| Message-ID | <ozOKS.8897$453.6830@fx23.iad> |
| In reply to | #95735 |
On 2026-11-16, Rich <rich@example.invalid> wrote: > Charlie Gibbs <cgibbs@kltpzyxm.invalid> wrote: > >> Indeed. Thanks for the help. Unfortunately, my tests have suddenly >> stopped working - pgmtopbm has seemingly started ignoring my threshold >> setting. Stripping down the commands to work on a single-page PDF: >> >> $ gs -dNOPAUSE -q -r300 -sDEVICE=pgmraw -dBATCH -sOutputFile=testfile3.pgm testfile.pdf >> $ pgmtopbm -threshold -value 0.82 testfile3.pgm >testfile3.pnm >> $ pnmtotiff -g4 <testfile3.pnm >testfile3.tif >> >> Is there something wrong with my pgmtopbm command? > > Not that I see from the above example, other than the result file > should be named ".pbm" as it is a Portable Bit Map (monochrome) file. > But so long as you use the same name to feed into pnmtotiff it won't > matter a bit what you name it. > >> If I remove the "-threshold -value 0.82" parameters >> the output (testfile3.pnm) is exactly the same. > > Weird. I would expect some change, as it is supposed to be outputting > pbm, and you should be sending in greyscale, so the two files should > differ. It's frustrating that I got it to work once. I tried purging and re-installing the netpbm package in case something got corrupted, but it made no difference. If I give a bogus threshold value (e.g. 2) pgmtopbm issues an error message. I also tried moving the -threshold -value parameter ahead of the input file name, but that made no difference. I tried arranging the command-line parameters in many different orders, e.g. $ pgmtopbm >testfile3.pbm testfile3.pgm -value 0.82 -threshold The result still came out the same. However, leaving out "-threshold": $ pgmtopbm testfile3.pgm -value 0.82 >testfile3.pbm gave a page with a light gray backround rather than a white one. That's the only way I've managed to get the output to change. Curiouser and curiouser... -- /~\ Charlie Gibbs | In this world there are \ / <cgibbs@kltpzyxm.invalid> | two kinds of people: X I'm really at ac.dekanfrus | 1. Those who can extrapolate / \ if you read it the right way. | from incomplete data.
[toc] | [prev] | [next] | [standalone]
| From | not@telling.you.invalid (Computer Nerd Kev) |
|---|---|
| Date | 2026-11-17 07:25 +1000 |
| Message-ID | <6afb74c5@news.ausics.net> |
| In reply to | #95719 |
Charlie Gibbs <cgibbs@kltpzyxm.invalid> wrote: > On 2026-11-16, Nuno Silva <nunojsilva@invalid.invalid> wrote: >> Consider having a look at ImageMagick's convert with -lat, "local >> adaptive thresholding". Sadly, my notes don't go beyond saying it's >> better than just threshold... example command line: >> >> convert in.pnm -lat 100x700-15% out.pbm >> >> <https://usage.imagemagick.org/transform/#lat> > > That sounds interesting! I'll give it a look. If you're not just after a quick fix, I've had some success with this script which runs a sequence of ImageMagick filters including "-lat": http://www.fmwconcepts.com/imagemagick/textcleaner/index.php As shown by the examples, it can take quite a few goes to narrow down on the best arguments to use for a particular document. Its greyscale output can be converted to monochrome with an appropriate threshold (ImageMagick can do this too) if desired. >> (unpaper might also be useful, depending on how the input documents >> are?:) >> >> <https://flameeyes.com/projects/unpaper> Interesting, I might try that out. Another program that has some similar features is Scan Tailor. I've only used the original, but there's a maintained fork called Tcan Tailor Advanced here: https://scantailor.net/ -- __ __ #_ < |\| |< _#
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.os.linux.misc
csiph-web