Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the JPEG2000-encoded wallpaper image from the WdS handout as is #24

Closed
wants to merge 4 commits into from

Conversation

davidfoerster
Copy link
Contributor

The installation script downloads a suitably licensed official PDF handout, extracts its wallpaper image for later use in Heldendokument. Currently, this wallpaper is transcoded to JPEG which is both lossy and results in a larger file size than the original.

This pull request modifies the installation process:

  1. Invoke pdimages such that it extracts the exact bitstream of the wallpaper images. Move the resulting JPEG2000 file to wallpaper.jp2.
  2. Tell LuaTeX how to handle images with the .jp2 file extension.
  3. Tell LuaTeX the new wallpaper image file name.

Caveat: The wallpaper bitstream contains the image with inverted greyscale colours. Suitable PDF commands then invert the colours back to the expected result and, luckily, the graphicx module provides an undocumented option \includegraphics[decodearray=…]{…} to do just that. Unfortunately, not all PDF viewers support this PDF feature and Blink (Chrome, Edge, etc.) is among them. I successfully tested them in Adobe Reader, Firefox, Okular, Evince, and QPdfviewer. As a workaround, one may open the PDF using a compatible viewer and “print” it to a new PDF file or pass it through Ghostscript with -dCompatibilityLevel=1.4 (which will decode and colour-transform the wallpaper image and store it in a lossless format inside the resulting PDF).

Other minor change(s):

  • Don’t include the file extension when specifying the path to the logo on the front page header (currently logo-fanprodukt.png). This makes it trivial to replace the image with something in a different format (JPEG, EPS, etc.) in case anybody wants to do that.

If we extract the wallpaper bit stream from the WdS handout we get JPEG2000.
It’s much better to preserve the original encoding than to re-encode.

Unfortunately the wallpaper now has inverted colors which we can remedy with a
"secret" \includegraphics option: "decodearray={1 0 }". To apply it to the
wallpaper we need to adjust \ThisCenterWallPaper to pass an optional parameter
to \includegraphics.
@davidfoerster davidfoerster marked this pull request as ready for review March 22, 2024 19:27
@flyx
Copy link
Owner

flyx commented Mar 24, 2024

Habe ein resultierendes PDF getestet:

Preview (macOS), Skim (macOS), GoodReader (iOS)

Farben sind invertiert:

Screenshot 2024-03-24 at 20 27 53

Adobe Acrobat Reader 2023.001.20063

Kann die Datei laden, zeigt aber eine Fehlermeldung und stellt den Hintergrund gar nicht dar:

Screenshot 2024-03-24 at 20 29 57

Firefox

Der einzige Renderer den ich installiert habe, der die Datei korrekt anzeigen kann.


Der Support für dieses Feature ist zu schlecht, als dass ich das mergen möchte. Prinzipiell wäre es schön, das Bild nicht zu transcodieren, aber eine akzeptable Lösung dafür muss breiter unterstützt werden als diese. Insbesondere ist wichtig, dass das PDF auf Tablets (iPad, reMarkable, …) korrekt dargestellt wird – die sind in meinem Umfeld die üblichen Systeme, mit denen der Bogen angeschaut wird.

Danke trotzdem für deine Mühe, vielleicht findest du noch eine Option die besser funktioniert.

@flyx flyx closed this Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants