themillhousegroup / scala-thumbnailer   0.5.1

GNU General Public License v2.0 only Website GitHub

:volcano: Library to generate file thumbnails in Scala

Scala versions: 2.12

A Scala library for generating thumbnails.

The API uses streams rather than files. Supports the following file types:

  • PDF
  • PNG, JPEG, GIF, BMP
  • DOCX
  • Plain text files

GPL v2.0

This fork exists to update the following versions:

  • Scala - v2.12 family
  • Apache PDFBox library dependency to the 2.x family
  • Typesafe Scala Logging to the 3.5.x family

... and get it published on Maven Central

Usage

Create

val defaultThumbnailer = new Thumbnailer
val thumbnailer = new Thumbnailer(new PDFThumbnailer, new TextThumbnailer)

Output to stream

val thumbnailer = new Thumbnailer
val input = new FileInputStream("input.pdf")
val output = new FileOutputStream("output.png", false)

thumbnailer.generateThumbnail(input, output, "application/pdf")

output.close
input.close

Output to byte array

val thumbnailer = new Thumbnailer
val input = new FileInputStream("input.pdf")

val bytes: Array[Byte] = thumbnailer.generateThumbnail(input, "application/pdf")

input.close

Options

val thumbnailer = new Thumbnailer
thumbnailer.setSize(100, 200)
thumbnailer.setShouldPadThumbnail(false)

Dependency Management

SBT

libraryDependencies += "com.themillhousegroup" %% "scala-thumbnailer" % "0.5.1"

Homepage

Originally inspired by java-thumbnailer.