package ru.makingpages.katto.test;
import org.apache.commons.io.IOUtils;
import ru.makingpages.katto.Katto;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
/**
* User: greg
*/
public class ThumbExample {
public static void main(String... args) throws IOException {
final InputStream in = ThumbExample.class.getResourceAsStream("/pic.jpg");
String currentDir = System.getProperty("user.dir");
String fileSeparator = System.getProperty("file.separator");
final File outFile = new File(currentDir + fileSeparator + "pic_thumb.jpg");
outFile.createNewFile();
final byte[] originalImage = IOUtils.toByteArray(in);
final byte[] resizedData = new Katto().setOriginalData(originalImage).setQuality(1f).setTargetWidth(400).resize();
FileOutputStream fos = new FileOutputStream(outFile);
IOUtils.write(resizedData, fos);
System.out.println(currentDir + fileSeparator + "pic_thumb.jpg");
}
}