Repository navigation
Extract the media inside PDFs, web pages, MHTML and Safari web archives - #250
Merged
Merged
Conversation
A PDF, an HTML page, an MHTML file or a Safari web archive was "other" and was dropped at ingest, so the pictures and videos inside one never reached a case. A saved offline page in Chrome or Brave, for one, holds every image the page showed. gleapp/docmedia.py reads them. With "Extract media from documents" ticked at ingest (or "documents": true in a job file), each one is kept as a container, like a zip, and gleapp/nested.py registers what is inside, linked by container_id: - PDF (pypdf): every image object, drawn on a page or not, and every attached file. A JPEG or JPEG 2000 stream is the file as the producer wrote it and comes out byte for byte; any other image is stored as pixels and is rebuilt as a PNG named _rebuilt, whose hashes are GLEAPP's. A PDF with no extension is recognized by its magic. An encrypted PDF that opens without a password is read. - HTML: images and videos in data: URIs (img, video, srcset, CSS url()). - MHTML and web archives: every image and video part, named from its URL, plus any data: URI in their HTML. Byte for byte. - Images under 32 pixels on a side are left out. A case ingested without documents can open them later: "Extract media from documents" in the sidebar goes back over the sources (folders, extraction archives and disk images, through archive.ingest_archive with only_documents) and adds what the first ingest left out. A second run adds nothing; a source no longer where the case recorded it is named and skipped. In the gallery: - The details pane says where an item was found (the document, the page, the attachment or the saved resource) and whether it is byte for byte or rebuilt, and "Show everything from this document" lists what came out of one. - The sidebar section "Archives and documents" shows the counts for each, with a checkbox under each button for the files pulled out of an archive or a document. - The Type filter's "archive (container)" is split into Archives, Documents and App cache pieces (ExoPlayer), told apart in SQL; a SQLite function on the case connection applies exoprobe's own rule for cache piece names. - The counts refresh as soon as the extraction is done, before processing and hash matching finish. Two gaps found on the way are closed here too. JPEG 2000 (.jp2, .j2k, .j2c, .jpf, .jpx, and the JP2 box and codestream magic) was not an image anywhere in GLEAPP, so a PDF's JPXDecode image was dropped. And pypdf decrypts AES only through pycryptodome or cryptography, not the pycryptodomex GLEAPP already had, so pycryptodome is added beside pypdf (both BSD). The manual and help describe the option, the button, the sidebar and what each document type yields. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A PDF, HTML page, MHTML file or Safari web archive was classed as "other" and dropped at ingest, so the pictures and videos inside one never reached a case. A saved offline page in Chrome or Brave, for example, holds every image the page showed.
What it does
New
gleapp/docmedia.py. With Extract media from documents ticked at ingest (or"documents": truein a job file), each document is kept as a container, like a zip, andgleapp/nested.pyregisters what is inside, linked bycontainer_id._rebuilt, hashes are GLEAPP's)data:URIs (img,video,srcset, CSSurl())data:URIs in their HTMLsrc="photo.jpg"link is not content; that file sits beside the page and is ingested on its own.Cases ingested without it
Extract media from documents in the sidebar goes back over the case's sources (folders, extraction archives and disk images, via
archive.ingest_archivewithonly_documents) and adds what the first ingest left out. A second run adds nothing, and a source no longer where the case recorded it is named and skipped.Gallery
kind=archivestill means every container. A SQLite function on the case connection applies exoprobe's own rule for cache piece names.Two gaps closed on the way
.jp2 .j2k .j2c .jpf .jpx, the JP2 box and the codestream magic) was not an image anywhere in GLEAPP, so a PDF'sJPXDecodeimage was dropped. It is now an image everywhere; the viewer and the report already convert non-browser formats.pycryptodomeorcryptography, not thepycryptodomexGLEAPP already had.pycryptodomeis added besidepypdf(both BSD) and collected in the spec.Dependencies
pypdf>=5.0(BSD-3, pure Python)pycryptodome>=3.20(BSD-2 / public domain; same project and wheels as pycryptodomex, installs beside it)Both credited in the manual and help.
Tests
tests/test_docmedia.py(21): each reader, byte-for-byte MD5s, rebuilt PNGs, attachments, size floor, AES/RC4 PDFs, JPEG 2000, folder and zip ingest, documents inside a zip, adding documents later (and a second run adding nothing), a missing source, details-pane info, container filters and counts, and the early count refresh.test_back_to_place.py: one pinned line updated for the new "everything from this document" view.check_wheelpass.Not covered
BI … EI).🤖 Generated with Claude Code