dschmidt opened a new pull request, #3096:
URL: https://github.com/apache/tika/pull/3096

   Getting "the thumbnail of this file" out of Tika takes format knowledge on 
the client: the THUMBNAIL of a Word or Excel file is an EMF/WMF whose usable 
form is the RENDERING underneath it, a PDF has no THUMBNAIL but a page 
RENDERING, the THUMBNAIL of a DOCX inside a ZIP is not the ZIP's, and with 
rendering enabled the picture of an embedded OLE object is a RENDERING too, 
plus the request configuration that switches the renderers on.
   
   `POST`/`PUT /unpack/thumbnail`, next to `/unpack` and `/unpack/all`, answers 
with the thumbnail as JSON: the `/rmeta` metadata object of the embedded 
document that is the thumbnail and the image as base64, or `204` if the 
document has none.
   
   ```
   {
     "metadata": { "Content-Type": "image/png", "tiff:ImageWidth": "800", 
"tk:embedded-resource-type": "RENDERING", ... },
     "image": "iVBORw0KGgo..."
   }
   ```
   
   It is one forked parse in unpack mode with a fixed parse context: text 
extraction off, PDF page 1 rendered at 96 dpi without OCR, EMF/WMF thumbnails 
rendered (`renderOnlyEmbeddedResourceTypes: ["THUMBNAIL"]`, from #3095, so the 
pictures of embedded objects are not rendered), OCR of images off, only 
THUMBNAIL and RENDERING embedded documents extracted, together with their 
metadata. `ThumbnailSelector` then picks, in this order, the raster THUMBNAIL 
directly below the document, the rendering of a vector THUMBNAIL, or the 
RENDERING of the first page. It extracts what the document carries; it does not 
resize or convert. A request-supplied parser configuration wins over the fixed 
one.
   
   Verified against a server built from main plus the open thumbnail PRs: docx, 
xlsx, doc, xls, ppt, pptx, odt, epub, GeoGebra, Pages, Numbers, Keynote, mp3, 
m4a, flac, ogg, pdf, nef and pef all answer with the right image; a zip, a 
plain jpeg and a doc without a thumbnail answer 204. Raw camera files need 
their file name (`Content-Disposition`), as they are detected by extension.
   
   Note: `embedded-limits.maxDepth` is 3 in the fixed context because of the 
off-by-one in the depth limit (separate ticket); 2 would be correct once that 
is fixed.
   
   https://issues.apache.org/jira/browse/TIKA-4856
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to