Thumbnail image is almost used by any application that deal with image visualization. This how-to demonstrates how to generate it using Java and Marvin.

First, use static import for MarvinPluginCollection class to have access to its static methods directly on your class.

import static marvin.MarvinPluginCollection.*;

You can generate thumbnails passing its width with thumbnailByWidth(...) or its height with thumbnailByHeight(...)

original:


width = 150:


height = 80:


Source:

MarvinImage image = MarvinImageIO.loadImage("./res/jaguar.jpg");
MarvinImage thumbnail = new MarvinImage();
//Thumbnail width == 150
thumbnailByWidth(image, thumbnail, 150);
MarvinImageIO.saveImage(thumbnail, "./res/jaguar_thumb_w150.jpg");
//Thumbnail height == 80
thumbnailByHeight(image, thumbnail, 80);
MarvinImageIO.saveImage(thumbnail, "./res/jaguar_thumb_h80.jpg");

Was this how-to helpful? Share it:

Do not you know how to setup Marvin? Read how to develop your First Application.