🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.os.linux.misc
36 messages
36 total messages Started by Charlie Gibbs Sun, 15 Nov 2026 00:56
Shrinking huge PDF files
#2581
Author: Charlie Gibbs
Date: Sun, 15 Nov 2026 00:56
29 lines
1953 bytes
[Here's an on-charter post for a change...]

I was given some scans of sheet music from an iPad vict^H^H^H^Huser who
couldn't find the settings (if it has any) for its scanning function.
As a result, she wound up with a 9-page PDF file that takes up over
30 megabytes.  (When I scan a similar document on my machine the file
is about one megabyte.)  A bit of digging came up with utilities that
tell me that her scan is in 24-bit colour at some ungodly resolution
(using JPEG to keep it from being even bigger).

I've been looking at utilities like Ghostscript, but the documentation
is making my eyes glaze over.  Is there a guide that can help me
re-sample the file, say to 300 dpi in monochrome?

I suppose the alternative would be to have the user find someone
who could help her beat macOS into submission, but that might
wind up more like that episode of "The Big Bang Theory":

Leonard: Oh, screw the roommate agreement.
Sheldon: No!  You don't screw the roommate agreement.
          The roommate agreement screws _you_!

aTdHvAaNnKcSe...

-- 
/~\  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.
Re: Shrinking huge PDF files
#2582
Author: Carlos E.R.
Date: Sun, 15 Nov 2026 01:16
28 lines
2116 bytes
On 2026-11-15 01:56, Charlie Gibbs wrote:
> [Here's an on-charter post for a change...]
> 
> I was given some scans of sheet music from an iPad vict^H^H^H^Huser who
> couldn't find the settings (if it has any) for its scanning function.
> As a result, she wound up with a 9-page PDF file that takes up over
> 30 megabytes.  (When I scan a similar document on my machine the file
> is about one megabyte.)  A bit of digging came up with utilities that
> tell me that her scan is in 24-bit colour at some ungodly resolution
> (using JPEG to keep it from being even bigger).
> 
> I've been looking at utilities like Ghostscript, but the documentation
> is making my eyes glaze over.  Is there a guide that can help me
> re-sample the file, say to 300 dpi in monochrome?

Convert to some bitmap image format, file per page (png, for instance)
resample using gimp, or magick
convert back to PDF, if that is the goal.


Hint: don't fight documentation. Ask an AI to guide you on the use of 
ghostscript (if that is the tool you want to use). AIs are good at this.

(no, I did not ask an AI for this post)

-- 
Cheers, Carlos.
ES🇪🇸, EU🇪🇺;
Re: Shrinking huge PDF files
#2583
Author: Nuno Silva
Date: Sun, 15 Nov 2026 01:28
60 lines
3739 bytes
On 2026-11-15, Charlie Gibbs wrote:

> [Here's an on-charter post for a change...]
>
> I was given some scans of sheet music from an iPad vict^H^H^H^Huser who
> couldn't find the settings (if it has any) for its scanning function.
> As a result, she wound up with a 9-page PDF file that takes up over
> 30 megabytes.  (When I scan a similar document on my machine the file
> is about one megabyte.)  A bit of digging came up with utilities that
> tell me that her scan is in 24-bit colour at some ungodly resolution
> (using JPEG to keep it from being even bigger).
>
> I've been looking at utilities like Ghostscript, but the documentation
> is making my eyes glaze over.  Is there a guide that can help me
> re-sample the file, say to 300 dpi in monochrome?
>
> I suppose the alternative would be to have the user find someone
> who could help her beat macOS into submission, but that might
> wind up more like that episode of "The Big Bang Theory":
>
> Leonard: Oh, screw the roommate agreement.
> Sheldon: No!  You don't screw the roommate agreement.
>           The roommate agreement screws _you_!
>
> aTdHvAaNnKcSe...

If the pages are regular images in the PDF (and not e.g. some composite
image using some technique to achieve separate layers using different
images in the same page), I'd extract them with pdfimages (from
libpoppler, probably with the -all option (-j has served me well in the
past, but I should have chosen -all?)), convert to a different
colorspace using imagemagick or equivalent, and then either re-assemble
these in a PDF file or create a ZIP file with the extension .CBZ (in
case that increases the chances of document viewers handling it as a
collection of pages in a ZIP archive).

(Actually, I'd probably first see if they could convert to monochrome
well, playing with the threshold in imagemagick's convert, and if so I'd
instead use cjb2 and djvm to turn the whole thing into a DjVu file.)

But IIRC Ghostscript does indeed have something for resolution and
colorspace, let me see if I have something written down... yes, part of
a command I wrote down has:

    gs -sDEVICE=pdfwrite -sColorConversionStrategy=Gray \
       -sProcessColorModel=DeviceGray

But I have no idea if this actually worked or if it was just something I
wrote down while trying to make it work.


From a web search, I guess this is the web version of the current
manual?:
<https://ghostscript.readthedocs.io/en/latest/VectorDevices.html>

(Also see {Color,Gray,Mono}ImageResolution, which are listed there but
are not documented at least on this section?)

-- 
Nuno Silva
Re: Shrinking huge PDF files
#2584
Author: Lawrence D’Oliveiro
Date: Sun, 15 Nov 2026 01:49
10 lines
1595 bytes
On Sun, 15 Nov 2026 00:56:16 GMT, Charlie Gibbs wrote:

> I've been looking at utilities like Ghostscript, but the
> documentation is making my eyes glaze over.

According to the docs
<https://ghostscript.readthedocs.io/en/gs10.08.0/Devices.html>, the
“pngmono” and “pngmonod” output devices should give you 1 bit per
pixel, with the latter doing error-diffusion dithering. Or have a look
at some of the other device options there.
Re: Shrinking huge PDF files
#2585
Author: 🇵🇱Jacek Marcin Jaworski🇵🇱
Date: Sun, 15 Nov 2026 02:26
90 lines
5148 bytes
Z totaliztycznym salutem!

NOTE: THIS IS ONLY DESCRIPTION "HOW TO CREATE HIGHLY COMPRESSED 
BLACK-AND-WHITE PDFS". SO IT IS UP TO YOU WRITE YOUR OWN USABLE SHELL 
SCRIPT!!! BECAUSE IT IS INFO FOR CLEVER HACKERS NOT FOR LAZY AND 
BRAINLESS LAMERS!!! THIS BROCHURE INTENTIONALLY RESPECT PROVERB: "A WORD 
TO THE WISE IS SUFFICIENT."

Originally this was brochure written in polish "Skanowanie i Tworzenie 
Dok. PDF w Sys. Debian Ubuntu", chapter "4.1 Tworzenie Czarnobiałych 
Dok. PDF". This brochure is available as a PDF eBook from my WWW home 
page. It is available for free (as in "free beer").

<https://energokod.gda.pl/monografie/Skanowanie%20i%20Tworzenie%20Dok.%20PDF%20w%20Sys.%20Debian-Ubuntu.pdf>

Translation was generated today by ChatGPT (OpenAI, GPT6):

> ## 4.1 Creating Black-and-White PDF Documents
> 
> Official documents, many university lecture notes, and numerous books are published in black and white. This makes it possible to significantly reduce the size of the resulting PDF document.
> 
> The process of creating a PDF document consists of several steps:
> 
> 1. Converting PNG files to PBM;
> 2. Converting PBM files to DJVU;
> 3. Combining all DJVU files into a single DJVU file;
> 4. Converting the resulting DJVU file into the final PDF file.
> 
> Conversion to DJVU is necessary because this format currently provides the best compression for scanned images containing text. Conversion to PBM is necessary because this is the input format accepted by the `cjb2` program, which generates DJVU files.
> 
> ```bash
> # To convert PNG files to PBM, call the following
> # command in a loop:
> convert "$lPNG" "$lPBM"
> ```
> 
> Of course, you must assign the names of the files being converted to the `lPNG` and `lPBM` variables.
> 
> ```bash
> # To convert PBM files to DJVU, call cjb2
> # (Simple DjVuBitonal encoder) in a loop:
> cjb2 -clean "$lPBM" "$lDJVU"
> ```
> 
> Of course, you must assign the names of the files being converted to the `lPBM` and `lDJVU` variables.
> 
> ```bash
> # To merge individual DJVU files into a single
> # temporary file named tmp.djvu:
> djvm -c "./tmp.djvu" $(find . -maxdepth
> 1 -type f -iname '*.djvu' | nsort)
> ```
> 
> `nsort` is my own utility, which sorts filenames by their numeric values rather than by their ASCII codes.
> 
> As an alternative, you can use the standard system `sort` command, provided that you use filenames with leading zeros, e.g. `00001.png`, `00002.png`, and so on.
> 
> ```bash
> # To convert the merged DJVU file to PDF:
> ddjvu -format=pdf -quality=150
> "./tmp.djvu" "$gNazwaPDF"
> ```
> 
> `-quality=150` provides the best quality.
> 
> For testing purposes, I scanned the first four pages of an article entitled "The Return of Kakuro", from issue 77 (1/2025) of the two-colour magazine *Świat Matematyki*.
> 
> To demonstrate the effectiveness of the compression, I also combined the PNG files into a PDF using the following command:
> 
> ```bash
> convert $(find . -maxdepth 1 -type f -
> iname '*.png' | nsort) 'Powrót Kakuro.v2.pdf'
> ```
> 
> The resulting files had the following sizes:
> 
> ```text
> 256975  'Powrót Kakuro.pdf'
> 637496  'Powrót Kakuro.v2.pdf'
> 154399  'Powrót Kakuro.djvu'
> ```
> 
> This means that the resulting `Powrót Kakuro.pdf` file was 166% larger than the DJVU version, while the lossless version was 248% larger.

-- 
Z totaliztycznym salutem!
Jacek Marcin Jaworski,  Pruszcz Gd., woj. Pomorskie, Polska 🇵🇱, UE 🇪🇺;
Pryw. s. WWW: <https://energokod.gda.pl>; Pryw. tel.: +48-609-170-742;
Netykieta:                  <https://energokod.gda.pl/Netykieta.html>.
Re: Shrinking huge PDF files
#2586
Author: Rich
Date: Sun, 15 Nov 2026 03:16
53 lines
3309 bytes
Charlie Gibbs <cgibbs@kltpzyxm.invalid> wrote:
> [Here's an on-charter post for a change...]
> 
> I was given some scans of sheet music from an iPad vict^H^H^H^Huser who
> couldn't find the settings (if it has any) for its scanning function.
> As a result, she wound up with a 9-page PDF file that takes up over
> 30 megabytes.  (When I scan a similar document on my machine the file
> is about one megabyte.)  A bit of digging came up with utilities that
> tell me that her scan is in 24-bit colour at some ungodly resolution
> (using JPEG to keep it from being even bigger).
> 
> I've been looking at utilities like Ghostscript, but the documentation
> is making my eyes glaze over.  Is there a guide that can help me
> re-sample the file, say to 300 dpi in monochrome?

If it really is a "scan" (as in an image of a sheet of paper) and if 
you are fine with it becoming monochrome, then you can do this:

$ gs -dNOPAUSE -q -r300 -sDEVICE=tiffg4 -dBATCH -sOutputFile=page%02d.tiff big-monster.pdf

This will give you a set of tiffg4 monochrome images, one for each 
page, at 300dpi.

Then, you can reassemble a pdf by using 'tiff2pdf' from the libtiff 
package like so:

$ tiffcp page*.tiff multi-page.tiff
$ tiff2pdf -o new-smaller-file.pdf multi-page.tiff


Note, if it is a 24bit scan, and the black's are not really black but 
instead a dark grey, then the above will create a dithered output that 
will look awful and will not G4 compress well at all.

In which case, you have extra work to do (and you also need the netpbm 
utilities).  First, convert to grey scale:

$ gs -dNOPAUSE -q -r300 -sDEVICE=pgmraw -dBATCH -sOutputFile=page%02d.pgm big-monster.pdf

Then threshold the grey scale to black, and convert back to G4 tiffs:

$ for page in page*.pgm ; do pgmtopbm -threshold -value 0.82 $page | pnmtotiff -g4 > ${page%.pgm}.tiff ; done

Set each tiff to say it is 300dpi

$ for page in page*.tiff ; do tiffset -s 296 2 $page ; tiffset -s 282 300 $page ; tiffset -s 283 300 $page ; done

Create a multipage tiff from the individual single page tiffs and then 
create a pdf from the multi-page tiff:

$ tiffcp page*.tiff multi-page.tiff 
$ tiff2pdf -o new-smaller-file.pdf multi-page.tiff
Re: Shrinking huge PDF files
#2594
Author: Andreas Eder
Date: Sun, 15 Nov 2026 09:50
60 lines
3425 bytes
On So 15 Nov 2026 at 00:56, Charlie Gibbs wrote:

> [Here's an on-charter post for a change...]
>
> I was given some scans of sheet music from an iPad vict^H^H^H^Huser who
> couldn't find the settings (if it has any) for its scanning function.
> As a result, she wound up with a 9-page PDF file that takes up over
> 30 megabytes.  (When I scan a similar document on my machine the file
> is about one megabyte.)  A bit of digging came up with utilities that
> tell me that her scan is in 24-bit colour at some ungodly resolution
> (using JPEG to keep it from being even bigger).
>
> I've been looking at utilities like Ghostscript, but the documentation
> is making my eyes glaze over.  Is there a guide that can help me
> re-sample the file, say to 300 dpi in monochrome?

What I do ro make pdfs smaller is the following:

# $1=input, $2=output
gs -q -dNOPAUSE -dBATCH \
  -sDEVICE=pdfwrite \
  -sOutputFile="$2" \
  -r1200 \
  -dAutoRotatePages=/None \
  -dCompressFonts=true \
  -dDetectDuplicateImages \
  -dEmbedAllFonts \
  -dPDFSETTINGS=/prepress \
  -dPrinted=false \
  $zdistill $zres \
  -f "$1"
#
# -r1200 is to avoid rendering on a tiny canvas, which can trip
#   heuristics of complicated fonts, as (relating to a Hans font) in:
#   https://bugs.ghostscript.com/show_bug.cgi?id=701753
# -dAutoRotatePages since no, we do not want pages randomly rotated.
# -dCompressFonts seems not to hurt, and can save notable space.
# -dDetectDuplicateImages similarly.
# -dEmbedAllFonts usually but doesn't always work to embed fonts,
#   except that if downscaling images with zres, have to override.
# -dPDFSETTINGS=/prepress needed for embedding with
#   45-2/watters-litigator/doc.pdf (tb140)
# -dPrinted=false is to preserve internal links within the pdf,
#   notably for the cover/cover3 in our tb*complete.pdf:
#   https://tex.stackexchange.com/questions/456896

For grayscale output, can add
  -sColorConversionStrategy=Gray \
  -dProcessColorModel=/DeviceGray \

You can find full notes (e.g., options no longer used) and runnable scripts:
https://github.com/TeXUsersGroup/tugboat/blob/trunk/misc/ps2pdf-tub
https://github.com/TeXUsersGroup/tugboat/blob/trunk/misc/ps2pdf-gray-tub

Hope this helps,

'Andreas

-- 
ceterum censeo redmondinem esse delendam
Re: Shrinking huge PDF files
#2595
Author: Russell Marks
Date: Sun, 15 Nov 2026 10:18
26 lines
2016 bytes
Charlie Gibbs <cgibbs@kltpzyxm.invalid> wrote:

> I was given some scans of sheet music from an iPad vict^H^H^H^Huser who
> couldn't find the settings (if it has any) for its scanning function.
> As a result, she wound up with a 9-page PDF file that takes up over
> 30 megabytes.  (When I scan a similar document on my machine the file
> is about one megabyte.)  A bit of digging came up with utilities that
> tell me that her scan is in 24-bit colour at some ungodly resolution
> (using JPEG to keep it from being even bigger).
>
> I've been looking at utilities like Ghostscript, but the documentation
> is making my eyes glaze over.  Is there a guide that can help me
> re-sample the file, say to 300 dpi in monochrome?

I'm not sure about that, but here's one thing I ended up using
recently to get smaller PDFs (possibly including some unnecessary
options):

  gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen \
   -dNOPAUSE -dBATCH -sOutputFile=out.pdf in.pdf

It won't always make the file smaller, but did for me in some cases.
That does a reduction to 72 DPI, but I think you can replace "/screen"
with "/printer" to get 300.

-Rus.
Re: Shrinking huge PDF files
#2597
Author: Nuno Silva
Date: Sun, 15 Nov 2026 10:40
40 lines
2744 bytes
On 2026-11-15, Carlos E.R. wrote:

> On 2026-11-15 01:56, Charlie Gibbs wrote:
>> [Here's an on-charter post for a change...]
>>
>> I was given some scans of sheet music from an iPad vict^H^H^H^Huser who
>> couldn't find the settings (if it has any) for its scanning function.
>> As a result, she wound up with a 9-page PDF file that takes up over
>> 30 megabytes.  (When I scan a similar document on my machine the file
>> is about one megabyte.)  A bit of digging came up with utilities that
>> tell me that her scan is in 24-bit colour at some ungodly resolution
>> (using JPEG to keep it from being even bigger).
>>
>> I've been looking at utilities like Ghostscript, but the documentation
>> is making my eyes glaze over.  Is there a guide that can help me
>> re-sample the file, say to 300 dpi in monochrome?
>
> Convert to some bitmap image format, file per page (png, for instance)
> resample using gimp, or magick

For this I stress my recommendation of poppler's pdfimages. If I'm not
mistaken, it will extract the image streams, not convert them. If all it
has is one image per page, that's probably the best to avoid loss at
this stage.

(Well, if you do indeed convert to raster here, instead of extracting,
you can probably use this step to convert the colorspace and (if needed)
downsample the images.)

> convert back to PDF, if that is the goal.
>
>
> Hint: don't fight documentation. Ask an AI to guide you on the use of
> ghostscript (if that is the tool you want to use). AIs are good at
> this.
>
> (no, I did not ask an AI for this post)

-- 
Nuno Silva
Re: Shrinking huge PDF files
#2602
Author: Carlos E.R.
Date: Sun, 15 Nov 2026 12:29
34 lines
2437 bytes
On 2026-11-15 11:40, Nuno Silva wrote:
> On 2026-11-15, Carlos E.R. wrote:
> 
>> On 2026-11-15 01:56, Charlie Gibbs wrote:
>>> [Here's an on-charter post for a change...]
>>>
>>> I was given some scans of sheet music from an iPad vict^H^H^H^Huser who
>>> couldn't find the settings (if it has any) for its scanning function.
>>> As a result, she wound up with a 9-page PDF file that takes up over
>>> 30 megabytes.  (When I scan a similar document on my machine the file
>>> is about one megabyte.)  A bit of digging came up with utilities that
>>> tell me that her scan is in 24-bit colour at some ungodly resolution
>>> (using JPEG to keep it from being even bigger).
>>>
>>> I've been looking at utilities like Ghostscript, but the documentation
>>> is making my eyes glaze over.  Is there a guide that can help me
>>> re-sample the file, say to 300 dpi in monochrome?
>>
>> Convert to some bitmap image format, file per page (png, for instance)
>> resample using gimp, or magick
> 
> For this I stress my recommendation of poppler's pdfimages. If I'm not
> mistaken, it will extract the image streams, not convert them. If all it
> has is one image per page, that's probably the best to avoid loss at
> this stage.

Ok, yes. Although I used convert loosely, what I wanted to do is extract 
the original image inside.



-- 
Cheers, Carlos.
ES🇪🇸, EU🇪🇺;
Re: Shrinking huge PDF files
#2623
Author: Charlie Gibbs
Date: Sun, 15 Nov 2026 23:31
70 lines
3946 bytes
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!

-- 
/~\  Charlie Gibbs                  |  Life is perverse.
\ /  <cgibbs@kltpzyxm.invalid>      |  It can be beautiful -
 X   I'm really at ac.dekanfrus     |  but it won't.
/ \  if you read it the right way.  |    -- Lily Tomlin
Re: Shrinking huge PDF files
#2628
Author: c186282
Date: Mon, 16 Nov 2026 03:16
73 lines
4796 bytes
On 11/15/26 18:31, 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!


   Umm ... a two/three/four-stage CL 'solution' to
   what SHOULD be easy ?

   PDFs have a very useful place, but for SOME
   purposes they're an over-complex disaster.
Re: Shrinking huge PDF files
#2632
Author: Charlie Gibbs
Date: Mon, 16 Nov 2026 05:04
34 lines
2118 bytes
On 2026-11-16, c186282 <c186282@nnada.net> wrote:

> On 11/15/26 18:31, Charlie Gibbs wrote:
>
>> Thanks, everyone, for your suggestions.  Here's a history of my
>> various attempts.

<snipped>

>    Umm ... a two/three/four-stage CL 'solution' to
>    what SHOULD be easy ?
>
>    PDFs have a very useful place, but for SOME
>    purposes they're an over-complex disaster.

Perhaps, but non-experts are used to them and they're an
easy way to transmit images.  And what I'm trying to do
is not easy; I've been handed a PDF file scanned at 2400
dpi in 24-bit colour, which I want to transform into a
monochrome file at 600 dpi.  The 30-to-1 size advantage
turns a file transfer that requires Google Drive or Dropbox
into a simple e-mail attachment that displays quickly and
is more readable.

Yes, the ultimate solution would to have the person scanning
the file set up appropriate settings.  But if that person
doesn't know the fine points of scanning and is at the mercy
of Apple (or Microsoft or whoever), this might not be an option.

-- 
/~\  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.
Re: Shrinking huge PDF files
#2633
Author: Mike Scott
Date: Mon, 16 Nov 2026 07:09
40 lines
2744 bytes
On 16/11/2026 05:04, Charlie Gibbs wrote:
> On 2026-11-16, c186282 <c186282@nnada.net> wrote:
> 
>> On 11/15/26 18:31, Charlie Gibbs wrote:
>>
>>> Thanks, everyone, for your suggestions.  Here's a history of my
>>> various attempts.
> 
> <snipped>
> 
>>     Umm ... a two/three/four-stage CL 'solution' to
>>     what SHOULD be easy ?
>>
>>     PDFs have a very useful place, but for SOME
>>     purposes they're an over-complex disaster.
> 
> Perhaps, but non-experts are used to them and they're an
> easy way to transmit images.  And what I'm trying to do
> is not easy; I've been handed a PDF file scanned at 2400
> dpi in 24-bit colour, which I want to transform into a
> monochrome file at 600 dpi.  The 30-to-1 size advantage
> turns a file transfer that requires Google Drive or Dropbox
> into a simple e-mail attachment that displays quickly and
> is more readable.

GIMP might possibly help? Off the top of my head, import your pdf with 
pages as layers, fiddle with colour, size and resolution, then export 
layers as pages in a pdf.

> 
> Yes, the ultimate solution would to have the person scanning
> the file set up appropriate settings.  But if that person
> doesn't know the fine points of scanning and is at the mercy
> of Apple (or Microsoft or whoever), this might not be an option.
> 


-- 
Mike Scott
Harlow, England
Re: Shrinking huge PDF files
#2634
Author: Carlos E.R.
Date: Mon, 16 Nov 2026 08:47
17 lines
1808 bytes
On 2026-11-16 00:31, Charlie Gibbs wrote:
> 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...

You can script conversion to grayscale instead. And you can downsample, too.

-- 
Cheers, Carlos.
ES🇪🇸, EU🇪🇺;
Re: Shrinking huge PDF files
#2635
Author: Nuno Silva
Date: Mon, 16 Nov 2026 08:56
88 lines
4909 bytes
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
djvu [Was: Re: Shrinking huge PDF files]
#2637
Author: Carlos E.R.
Date: Mon, 16 Nov 2026 10:15
30 lines
1909 bytes
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🇪🇺;
Re: djvu [Was: Re: Shrinking huge PDF files]
#2641
Author: Andy Burns
Date: Mon, 16 Nov 2026 13:18
8 lines
1317 bytes
"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 ?
Re: Shrinking huge PDF files
#2646
Author: Charlie Gibbs
Date: Mon, 16 Nov 2026 17:02
29 lines
1893 bytes
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.
Re: Shrinking huge PDF files
#2647
Author: Charlie Gibbs
Date: Mon, 16 Nov 2026 17:02
15 lines
1542 bytes
On 2026-11-16, Mike Scott <usenet.16@scottsonline.org.uk.invalid> wrote:

> GIMP might possibly help? Off the top of my head, import your pdf with 
> pages as layers, fiddle with colour, size and resolution, then export 
> layers as pages in a pdf.

That's an interesting possibility.  And maybe the Gimp can do some
equivalent of dodging to try to lighten up the shawdowed areas
before converting to monochrome.

-- 
/~\  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.
Re: Shrinking huge PDF files
#2649
Author: The Natural Philosopher
Date: Mon, 16 Nov 2026 18:17
20 lines
2166 bytes
On 16/11/2026 17:02, Charlie Gibbs wrote:
> On 2026-11-16, Mike Scott <usenet.16@scottsonline.org.uk.invalid> wrote:
> 
>> GIMP might possibly help? Off the top of my head, import your pdf with
>> pages as layers, fiddle with colour, size and resolution, then export
>> layers as pages in a pdf.
> 
> That's an interesting possibility.  And maybe the Gimp can do some
> equivalent of dodging to try to lighten up the shawdowed areas
> before converting to monochrome.
> 
Gimp can do all of that, and you can erase smudges etc, but a job of a 
minute it aint

-- 
There’s a mighty big difference between good, sound reasons and reasons 
that sound good.

Burton Hillis (William Vaughn, American columnist)
Re: Shrinking huge PDF files
#2651
Author: Rich
Date: Mon, 16 Nov 2026 18:55
18 lines
2117 bytes
Charlie Gibbs <cgibbs@kltpzyxm.invalid> wrote:
> Yes, the ultimate solution would to have the person scanning the file 
> set up appropriate settings.  But if that person doesn't know the 
> fine points of scanning and is at the mercy of Apple (or Microsoft or 
> whoever), this might not be an option.

Yes, the "proper fix" here is to have whomever scanned the original 
paper do a proper scan from the beginning.

Sadly, most normies have no idea and just accept the defaults, and then 
the scanner software makers further confuse things by doing silly 
things like making the UI entry for "black and white" actually map to 
8-bit grey scale because most folks think of "black and white photos" 
when they think black & white for a scan, which itself "is" a greyscale 
image.  Actually getting a monochrome scan out of some of the software 
(esp. the bundled software) can be a royal pain.

Re: djvu [Was: Re: Shrinking huge PDF files]
#2652
Author: Rich
Date: Mon, 16 Nov 2026 18:59
22 lines
2144 bytes
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.
Re: djvu [Was: Re: Shrinking huge PDF files]
#2653
Author: Rich
Date: Mon, 16 Nov 2026 19:00
15 lines
1816 bytes
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.
Re: Shrinking huge PDF files
#2654
Author: Rich
Date: Mon, 16 Nov 2026 19:01
6 lines
1515 bytes
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.
Re: Shrinking huge PDF files
#2655
Author: Charlie Gibbs
Date: Mon, 16 Nov 2026 19:20
27 lines
2065 bytes
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.
Re: Shrinking huge PDF files
#2656
Author: Leroy H
Date: Mon, 16 Nov 2026 20:03
18 lines
1497 bytes
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.

Re: Shrinking huge PDF files
#2661
Author: Computer Nerd Kev
Date: Mon, 16 Nov 2026 21:25
37 lines
2086 bytes
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/

-- 
__          __
#_ < |\| |< _#
Re: Shrinking huge PDF files
#2662
Author: Rich
Date: Mon, 16 Nov 2026 22:04
32 lines
2703 bytes
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.
Re: djvu [Was: Re: Shrinking huge PDF files]
#2666
Author: Carlos E.R.
Date: Tue, 17 Nov 2026 02:00
19 lines
1827 bytes
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🇪🇺;
Re: Shrinking huge PDF files
#2665
Author: Charlie Gibbs
Date: Tue, 17 Nov 2026 02:00
50 lines
3088 bytes
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.
Re: Shrinking huge PDF files
#2668
Author: c186282
Date: Tue, 17 Nov 2026 02:29
34 lines
3097 bytes
On 11/16/26 13:55, Rich wrote:
> Charlie Gibbs <cgibbs@kltpzyxm.invalid> wrote:
>> Yes, the ultimate solution would to have the person scanning the file
>> set up appropriate settings.  But if that person doesn't know the
>> fine points of scanning and is at the mercy of Apple (or Microsoft or
>> whoever), this might not be an option.
> 
> Yes, the "proper fix" here is to have whomever scanned the original
> paper do a proper scan from the beginning.

   Office environment - AIN'T GONNA HAPPEN.

   Lots of times I got complaints from staff because
   they couldn't e-mail a letter or PDF. Reason, way
   WAY too huge. They'd scanned stuff at 2400 or
   more and just pasted it in. Didn't know how to use,
   or wouldn't bother to use, image suites to shrink
   the things down. *I* always had to do it.

> Sadly, most normies have no idea and just accept the defaults, and then
> the scanner software makers further confuse things by doing silly
> things like making the UI entry for "black and white" actually map to
> 8-bit grey scale because most folks think of "black and white photos"
> when they think black & white for a scan, which itself "is" a greyscale
> image.  Actually getting a monochrome scan out of some of the software
> (esp. the bundled software) can be a royal pain.

   Also a diff between real, one channel, monochrome and
   a RGB/CMYK with the color saturation on all channels
   turned all the way down.

   99% of the pop, it it isn't dead easy then it's NOT
   gonna get done.
Re: Shrinking huge PDF files
#2768
Author: Nuno Silva
Date: Sun, 22 Nov 2026 11:00
27 lines
2487 bytes
On 2026-11-16, Rich wrote:

> Charlie Gibbs <cgibbs@kltpzyxm.invalid> wrote:
>> Yes, the ultimate solution would to have the person scanning the file 
>> set up appropriate settings.  But if that person doesn't know the 
>> fine points of scanning and is at the mercy of Apple (or Microsoft or 
>> whoever), this might not be an option.
>
> Yes, the "proper fix" here is to have whomever scanned the original 
> paper do a proper scan from the beginning.
>
> Sadly, most normies have no idea and just accept the defaults, and then 
> the scanner software makers further confuse things by doing silly 
> things like making the UI entry for "black and white" actually map to 
> 8-bit grey scale because most folks think of "black and white photos" 
> when they think black & white for a scan, which itself "is" a greyscale 
> image.  Actually getting a monochrome scan out of some of the software 
> (esp. the bundled software) can be a royal pain.

At least if the problem is that the document has a too high resolution
and too many colors, that likely means you might have better input to
work with than if it were smaller and bad.

Not that it can't be big and still nearly useless, it can...

-- 
Nuno Silva
Re: djvu [Was: Re: Shrinking huge PDF files]
#2774
Author: Nuno Silva
Date: Mon, 23 Nov 2026 00:13
39 lines
2676 bytes
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
Re: djvu [Was: Re: Shrinking huge PDF files]
#2775
Author: Carlos E.R.
Date: Mon, 23 Nov 2026 00:54
52 lines
3167 bytes
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🇪🇺;
Re: djvu [Was: Re: Shrinking huge PDF files]
#2782
Author: Andy Burns
Date: Mon, 23 Nov 2026 06:35
10 lines
1386 bytes
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.

Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads