Package ru.makingpages.katto.test

Source Code of ru.makingpages.katto.test.ThumbExample

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");
    }

}
TOP

Related Classes of ru.makingpages.katto.test.ThumbExample

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.