in src/main/java/org/apache/sling/thumbnails/internal/providers/TikaFallbackProvider.java [57:80]
public InputStream getThumbnail(Resource resource) throws IOException {
log.info("Extracting content thumbnail from {}", resource.getPath());
try {
log.debug("Extracting file contents");
String contents = extractContents(resource);
log.debug("Creating thumbnail of file contents");
int width = 500;
int height = 500;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics graphics = image.createGraphics();
JEditorPane jep = new JEditorPane("text/html", contents);
jep.setSize(width, height);
jep.print(graphics);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(image, OutputFileFormat.PNG.toString(), baos);
return new ByteArrayInputStream(baos.toByteArray());
} catch (SAXException | TikaException e) {
throw new IOException("Failed to generate thumbnail from " + resource.getPath(), e);
}
}