net.coobird.thumbnailator
Class Thumbnails

java.lang.Object
  extended by net.coobird.thumbnailator.Thumbnails

public final class Thumbnails
extends Object

This class provides a fluent interface to create thumbnails.

Usage:
The following example code demonstrates how to use the fluent interface to create a thumbnail from multiple files from a directory, resizing them to a maximum of 200 pixels by 200 pixels while preserving the aspect ratio of the original, then saving the resulting thumbnails as JPEG images with file names having thumbnail. appended to the beginning of the file name.

Thumbnails.of(directory.listFiles())
    .size(200, 200)
    .outputFormat("jpeg")
    .asFiles(Rename.PREFIX_DOT_THUMBNAIL);
 
For more examples, please visit the Thumbnailator project page.

Author:
coobird

Nested Class Summary
static class Thumbnails.Builder<T>
          A builder interface for Thumbnailator.
 
Method Summary
static Thumbnails.Builder<File> fromFilenames(Iterable<String> files)
          Indicate to make thumbnails for images with the specified filenames.
static Thumbnails.Builder<File> fromFiles(Iterable<File> files)
          Indicate to make thumbnails from the specified Files.
static Thumbnails.Builder<BufferedImage> fromImages(Iterable<BufferedImage> images)
          Indicate to make thumbnails from the specified BufferedImages.
static Thumbnails.Builder<InputStream> fromInputStreams(Iterable<? extends InputStream> inputStreams)
          Indicate to make thumbnails for images obtained from the specified InputStreams.
static Thumbnails.Builder<URL> fromURLs(Iterable<URL> urls)
          Indicate to make thumbnails for images with the specified URLs.
static Thumbnails.Builder<BufferedImage> of(BufferedImage... images)
          Indicate to make thumbnails from the specified BufferedImages.
static Thumbnails.Builder<File> of(File... files)
          Indicate to make thumbnails from the specified Files.
static Thumbnails.Builder<? extends InputStream> of(InputStream... inputStreams)
          Indicate to make thumbnails from the specified InputStreams.
static Thumbnails.Builder<File> of(String... files)
          Indicate to make thumbnails for images with the specified filenames.
static Thumbnails.Builder<URL> of(URL... urls)
          Indicate to make thumbnails from the specified URLs.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

of

public static Thumbnails.Builder<File> of(String... files)
Indicate to make thumbnails for images with the specified filenames.

Parameters:
files - File names of image files for which thumbnails are to be produced for.
Returns:
Reference to a builder object which is used to specify the parameters for creating the thumbnail.
Throws:
NullPointerException - If the argument is null.
IllegalArgumentException - If the argument is an empty array.

of

public static Thumbnails.Builder<File> of(File... files)
Indicate to make thumbnails from the specified Files.

Parameters:
files - File objects of image files for which thumbnails are to be produced for.
Returns:
Reference to a builder object which is used to specify the parameters for creating the thumbnail.
Throws:
NullPointerException - If the argument is null.
IllegalArgumentException - If the argument is an empty array.

of

public static Thumbnails.Builder<URL> of(URL... urls)
Indicate to make thumbnails from the specified URLs.

Parameters:
urls - URL objects of image files for which thumbnails are to be produced for.
Returns:
Reference to a builder object which is used to specify the parameters for creating the thumbnail.
Throws:
NullPointerException - If the argument is null.
IllegalArgumentException - If the argument is an empty array.

of

public static Thumbnails.Builder<? extends InputStream> of(InputStream... inputStreams)
Indicate to make thumbnails from the specified InputStreams.

Parameters:
inputStreams - InputStreams which provide the images for which thumbnails are to be produced for.
Returns:
Reference to a builder object which is used to specify the parameters for creating the thumbnail.
Throws:
NullPointerException - If the argument is null.
IllegalArgumentException - If the argument is an empty array.

of

public static Thumbnails.Builder<BufferedImage> of(BufferedImage... images)
Indicate to make thumbnails from the specified BufferedImages.

Parameters:
images - BufferedImages for which thumbnails are to be produced for.
Returns:
Reference to a builder object which is used to specify the parameters for creating the thumbnail.
Throws:
NullPointerException - If the argument is null.
IllegalArgumentException - If the argument is an empty array.

fromFilenames

public static Thumbnails.Builder<File> fromFilenames(Iterable<String> files)
Indicate to make thumbnails for images with the specified filenames.

Parameters:
files - File names of image files for which thumbnails are to be produced for.
Returns:
Reference to a builder object which is used to specify the parameters for creating the thumbnail.
Throws:
NullPointerException - If the argument is null.
IllegalArgumentException - If the argument is an empty collection.
Since:
0.3.1

fromFiles

public static Thumbnails.Builder<File> fromFiles(Iterable<File> files)
Indicate to make thumbnails from the specified Files.

Parameters:
files - File objects of image files for which thumbnails are to be produced for.
Returns:
Reference to a builder object which is used to specify the parameters for creating the thumbnail.
Throws:
NullPointerException - If the argument is null.
IllegalArgumentException - If the argument is an empty collection.
Since:
0.3.1

fromURLs

public static Thumbnails.Builder<URL> fromURLs(Iterable<URL> urls)
Indicate to make thumbnails for images with the specified URLs.

Parameters:
urls - URLs of the images for which thumbnails are to be produced.
Returns:
Reference to a builder object which is used to specify the parameters for creating the thumbnail.
Throws:
NullPointerException - If the argument is null.
IllegalArgumentException - If the argument is an empty collection.
Since:
0.3.1

fromInputStreams

public static Thumbnails.Builder<InputStream> fromInputStreams(Iterable<? extends InputStream> inputStreams)
Indicate to make thumbnails for images obtained from the specified InputStreams.

Parameters:
inputStreams - InputStreams which provide images for which thumbnails are to be produced.
Returns:
Reference to a builder object which is used to specify the parameters for creating the thumbnail.
Throws:
NullPointerException - If the argument is null.
IllegalArgumentException - If the argument is an empty collection.
Since:
0.3.1

fromImages

public static Thumbnails.Builder<BufferedImage> fromImages(Iterable<BufferedImage> images)
Indicate to make thumbnails from the specified BufferedImages.

Parameters:
images - BufferedImages for which thumbnails are to be produced for.
Returns:
Reference to a builder object which is used to specify the parameters for creating the thumbnail.
Throws:
NullPointerException - If the argument is null.
IllegalArgumentException - If the argument is an empty collection.
Since:
0.3.1