Skip to content
Snippets Groups Projects
Commit 82459b3d authored by cramakri's avatar cramakri
Browse files

MINOR: Code to check the time required to generate a thumbnail in Java.

SVN: 17533
parent 89512ada
No related branches found
No related tags found
No related merge requests found
/*
* Copyright 2010 ETH Zuerich, CISD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.systemsx.cisd.openbis.dss.generic.shared.utils;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.springframework.util.StopWatch;
import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel;
/**
* @author Chandrasekhar Ramakrishnan
*/
public class ThumbnailTiming
{
public static void main(String[] args)
{
StopWatch stopWatch = new StopWatch();
stopWatch.start("Loading");
File file =
new File(
"/Users/cramakri/Documents/_streams/Local/Live/20100615-Screening/small-plate-examples/lmc/H055-1A/H055-1A_A02_02_dapi1.jpg");
BufferedImage image = ImageUtil.loadImage(file);
stopWatch.stop();
stopWatch.start("Convert");
BufferedImage thumbnail = ImageUtil.createThumbnail(image, 120, 60);
stopWatch.stop();
stopWatch.start("Write");
try
{
FileOutputStream output = new FileOutputStream("foo.png");
ImageIO.write(thumbnail, "png", output);
} catch (IOException ex)
{
throw CheckedExceptionTunnel.wrapIfNecessary(ex);
}
stopWatch.stop();
System.out.println(stopWatch.prettyPrint());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment