Skip to content

TIKA-5032: Emit the stored preview of zip-based formats as THUMBNAIL - #3530

Merged
tballison merged 8 commits into
apache:mainfrom
dschmidt:TIKA-5032-zip-previews
Nov 5, 2026
Merged

tballison merged 8 commits into
apache:mainfrom
dschmidt:TIKA-5032-zip-previews

Conversation

@dschmidt

@dschmidt dschmidt commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Several zip-based formats carry a ready-made preview image, but Tika either has no type for them or only sees a plain zip, so /unpack/preset/thumbnail has nothing to serve.

ZipParser now asks a small ZipPreview table which entry is the preview for the container's type and marks that entry as THUMBNAIL:

Format Type (new) Preview
Comic book archive .cbz application/vnd.comicbook+zip first image in name order (__MACOSX/ and hidden files skipped)
Krita .kra application/x-krita preview.png
OpenRaster .ora image/openraster Thumbnails/thumbnail.png
FreeCAD .FCStd application/x-extension-fcstd thumbnails/Thumbnail.png
Procreate .procreate application/x-procreate QuickLook/Thumbnail.png
Sketch .sketch (43 and later) application/x-sketch previews/preview.png

All six are sub-types of application/zip and are added to ZipParser's zip specializations so the type is kept. Krita and OpenRaster are already identified by their mimetype entry through OpenDocumentDetector; the others by extension. Because the types are zip sub-types, a file with a colliding extension that is not a zip keeps its detected type: an Oracle tnsnames.ora stays text, a pre-43 Sketch file stays application/x-sqlite3. The preview is only picked on the ZipFile path: the comic rule needs the whole central directory.

Tests build their zips at runtime (no binary fixtures): the cover is picked by name regardless of archive order, macOS leftovers and ComicInfo.xml are ignored, each fixed path is marked, a missing preview marks nothing, and a plain .zip gets no thumbnail. Also checked by hand against one real file of each format: the preset returned exactly the stored preview for all six, and 204 before.

Follow-up once this and #3529 are merged: the 3MF thumbnail. It should follow the package's thumbnail relationship in _rels/.rels (http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail), as 3MF is an OPC package, rather than assume the usual /Metadata/thumbnail.png.

https://issues.apache.org/jira/browse/TIKA-5032

@dschmidt

dschmidt commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

@tballison jfyi: from all the PRs I've sent today, this kinda has the highest priority for me - I need it as a prerequisite for one or two followups :)

@tballison

Copy link
Copy Markdown
Contributor

merge upstream and a small tweak. lemme know if you have objections.

@dschmidt

dschmidt commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

No, of course not, looks reasonable :)

@tballison
tballison merged commit 9e9ed9e into apache:main Nov 5, 2026
4 checks passed
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