0

I am building an e-ink-based auto-refreshing "newspaper" as wall decoration for my home. The e-ink panel I'm using supports 4-bit greyscale, i.e. 16 different levels of grey.

I am preparing the contents using LaTeX and would like to rasterize it to a 4-bit greyscale format using Ghostscript. Due to the relatively low DPI of the panel (~150ppi) I'd like to use anti-aliasing using the different grey levels.

Unfortunately I can't seem to find a suitable output device in the Ghostscript docs.

I have found:

  • There's a 4-bit indexed color PNG output device, but I don't see how to set the palette
  • There's pnggray, but it's 8-bit
  • There's a 4-bit X11 output device, but running a headless X server just to screencap the output in the end seems super convoluted

Am I missing an option?

If I can't do this using Ghostscript, what would be the highest-quality way to turn the 8-bit greyscale PNG output into 4-bit greyscale?

  • SO is a programming Q&A platform and this question is not about programming. Questions about operating systems, their utilities, networking and hardware, are off topic here. [What topics can I ask about here?](https://stackoverflow.com/help/on-topic). Please delete this – Rob Jan 09 '23 at 09:10

1 Answers1

0

Having tried multiple combinations in GhostScript, I have to say when I did get anywhere near just gray the results were still 8 bit (see kens comment below) and thus less than desired, however some scriptable graphics apps use GhostScipt or other PDF handlers that then can batch convert a list using a settings file. Similar questions and answers abound here on StackOverflow There may be other ways such as using pngtopnm or dividing bits by 17 but life is short.

Here are the results in my goto app IrfanView it will keep mono as mono and coloured text is high fidelity even at 4 bits.

enter image description here

filelist.txt for above (/filelist=txtfile - use filenames from "txtfile" as input)

; UNICODE FILE - edit with care ;-)

C:\SandBox\apps\PDF\GS\10.00x32\bin\rgb.pdf
C:\SandBox\apps\PDF\GS\10.00x32\bin\SourceHelloWorld2.pdf

Batch Ini file severely trimmed just to show how settings are saved from GUI to be applied with above (/advancedbatch - apply Advanced Batch Dialog options to image (from INI file))

; UNICODE FILE - edit with care ;-)

[Batch]
AdvCrop=0
AdvCropX=0
...
AdvUseBPP=1
AdvBPP=16
AdvUseFSDither=1
AdvDecrQuality=1
AdvAutoRGB=0
...
AdvGray=1
...
...

So consider a graphics app as more appropriate (Windows IrfanView does not need GhostScript but its a 2nd optional dependency)

Others are cross platform so will use GhostScript) Gimp, ImageMagic or XnView etc. are hot favourites for depending on Ghostscript.

K J
  • 8,045
  • 3
  • 14
  • 36
  • 1
    With Ghostscript you would either need to create your own device or use a 4-bit screen to an 8-bit device, then strip the top nibble of each byte. There is no 'out of the box' solution for this (4-bit output is not a common requirement) – KenS Jan 09 '23 at 12:05