Fluent builder for generating a thumbnail from an uploaded image or PDF and saving it into content storage. Obtained by calling newThumbnailBuilder on the owning image manager, configured with the source stream, content type, target dimensions and output location, then executed by calling build. The generated thumbnail is always written as a PNG file.

Group: Builders


Methods

withSourceInputStream(InputStream inputStream)

Returns: ThumbnailBuilder

Sets the stream to read the source image or PDF from. The stream is closed by build.

ParameterDescription
inputStreamthe stream containing the source image or PDF

withContentType(String contentType)

Returns: ThumbnailBuilder

Sets the content type of the source, which selects how it is processed. Any type containing "image" is scaled as an image, and "application/pdf" has its first page rendered; anything else is rejected by build.

ParameterDescription
contentTypethe source's content type, for example "image/png" or "application/pdf"

withHeight(int height)

Returns: ThumbnailBuilder

Sets the height in pixels of the generated thumbnail. Used for image sources only; PDF sources are rendered at a quarter of the given width and ignore the height.

ParameterDescription
heightthe thumbnail height in pixels

withWidth(int width)

Returns: ThumbnailBuilder

Sets the width in pixels of the generated thumbnail. For a PDF source the page is rendered at a quarter of this width.

ParameterDescription
widththe thumbnail width in pixels

withOutputDir(String outputDir)

Returns: ThumbnailBuilder

Sets the content storage directory the generated thumbnail is written into. Required; build rejects the call if it has not been set.

ParameterDescription
outputDirthe content storage directory path to store the thumbnail under

withOutputFileName(String outputFileName)

Returns: ThumbnailBuilder

Sets the file name the generated thumbnail is stored under within the output directory. The content is always PNG, so give it a .png extension.

ParameterDescription
outputFileNamethe file name to store the thumbnail as

build()

Returns: void

Generates the thumbnail from the configured source and stores it at the configured output directory and file name. An image source is scaled to the configured width and height; a PDF source has its first page rendered at a quarter of the configured width. The output is always written as PNG. This does image decoding and content storage writes, so it is expensive.

To get full access to the Kademi Hub existing customers can login here, or new customers can register here.