diff --git a/docs/guide/index.md b/docs/guide/index.md index 1962e52..84a7a64 100644 --- a/docs/guide/index.md +++ b/docs/guide/index.md @@ -8583,7 +8583,7 @@ It is recommended that you learn about the common ways people mess up OPSEC [[Wikiless]](https://wikiless.com/wiki/Key_disclosure_law) [[Archive.org]](https://web.archive.org/web/https://en.wikipedia.org/wiki/Key_disclosure_law) and this other visual resource with law references [[Archive.org]](https://web.archive.org/web/https://www.gp-digital.org/world-map-of-encryption/). +Keep in mind that many countries have specific laws to compel you to reveal your passwords that could override your "right to remain silent". See this Wikipedia article: [[Wikiless]](https://wikiless.com/wiki/Key_disclosure_law) [[Archive.org]](https://web.archive.org/web/https://en.wikipedia.org/wiki/Key_disclosure_law) and this other visual resource with law references [[Archive.org]](https://web.archive.org/web/https://www.gp-digital.org/world-map-of-encryption/). Australia in particular has broad privacy laws[^536] and passed the Surveillance Legislation Amendment (Identify and Disrupt) Act 2021[^537], which grants authorities powers to modify, add, copy, and delete data on a suspect's devices and accounts. ## A small final editorial note diff --git a/scripts/convert.py b/scripts/convert.py index ebc4440..facd7e3 100644 --- a/scripts/convert.py +++ b/scripts/convert.py @@ -93,22 +93,28 @@ def apply_dark_theme( def _save_images_as_pdf(images: list, output_path: str) -> None: - """Save a list of RGB PIL images as a PDF using PNG compression via qpdf. + """Save a list of RGB PIL images as a PDF without requiring libjpeg. - Pillow's built-in PDF writer defaults to JPEG encoding for RGB images, - which fails when libjpeg is not available in the environment. Instead we - write each page as a lossless PNG to a temp directory and assemble them - with qpdf, which embeds the PNGs directly without re-encoding. + Pillow's PDF writer defaults to JPEG encoding for RGB images, which + fails when libjpeg is absent in the environment. Fix: quantize each + image to palette mode (256 colours, FASTOCTREE) so Pillow uses + zlib/deflate instead of JPEG, save each as an individual single-page + PDF, then merge the page PDFs with qpdf. + + Colour fidelity is preserved — the hacker theme uses only a handful + of distinct colours so 256-colour quantization is visually lossless. """ import tempfile as _tempfile with _tempfile.TemporaryDirectory() as staging: - png_paths = [] + page_pdfs = [] for i, img in enumerate(images): - p = os.path.join(staging, f'p{i:05d}.png') - img.save(p, format='PNG') - png_paths.append(p) + page_path = os.path.join(staging, f'p{i:05d}.pdf') + img.quantize(colors=256, method=Image.Quantize.FASTOCTREE).save( + page_path, format='PDF' + ) + page_pdfs.append(page_path) subprocess.run( - ['qpdf', '--empty', '--pages'] + png_paths + ['--', output_path], + ['qpdf', '--empty', '--pages'] + page_pdfs + ['--', output_path], check=True, )