* This program is free software; you can redistribute it and/or
* modify it under the terms of version 3 of the GNU Lesser General Public License
* or later as published by the Free Software Foundation.
-*/
+ */
package eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes;
private static void makeJpegThumbnail(File inputFile, File outputFile, java.awt.Dimension preferredTargetDimensions)
throws IOException, ImageFormatError {
- final BufferedImage inputImage = getBufferedImage(inputFile);
+ final BufferedImage inputImage = getBufferedImage(inputFile);
- final java.awt.Dimension sourceImageDimension = new java.awt.Dimension(
- inputImage.getWidth(), inputImage.getHeight());
+ final java.awt.Dimension sourceImageDimension = new java.awt.Dimension(
+ inputImage.getWidth(), inputImage.getHeight());
- final java.awt.Dimension targetDimensions = getTargetThumbnailDimension(
- sourceImageDimension, preferredTargetDimensions);
+ final java.awt.Dimension targetDimensions = getTargetThumbnailDimension(
+ sourceImageDimension, preferredTargetDimensions);
- final OutputStream out = new FileOutputStream(outputFile);
+ final OutputStream out = new FileOutputStream(outputFile);
- final Image scaledImage = scaleImage(inputImage,
- targetDimensions.width, targetDimensions.height);
+ final Image scaledImage = scaleImage(inputImage,
+ targetDimensions.width, targetDimensions.height);
- final BufferedImage bufferedImage = new BufferedImage(
- scaledImage.getWidth(null), scaledImage.getHeight(null),
- TYPE_INT_RGB);
+ final BufferedImage bufferedImage = new BufferedImage(
+ scaledImage.getWidth(null), scaledImage.getHeight(null),
+ TYPE_INT_RGB);
- final Graphics2D g = bufferedImage.createGraphics();
- g.drawImage(scaledImage, 0, 0, null);
- g.dispose();
+ final Graphics2D g = bufferedImage.createGraphics();
+ g.drawImage(scaledImage, 0, 0, null);
+ g.dispose();
- ImageIO.write(bufferedImage, "jpg", out);
- out.close();
+ ImageIO.write(bufferedImage, "jpg", out);
+ out.close();
}
private static void makeGifThumbnail(
System.out.println("Desired target image dimensions:" + targetDimensions);
- FileInputStream fiStream = new FileInputStream( inputFile );
+ FileInputStream fiStream = new FileInputStream(inputFile);
ImageReader reader = ImageIO.getImageReadersByFormatName("gif").next();
ImageInputStream stream = ImageIO.createImageInputStream(inputFile);
frame.image = bimage;
}
- ImageOutputStream output = new FileImageOutputStream(outputFile );
+ ImageOutputStream output = new FileImageOutputStream(outputFile);
GifSequenceWriter writer =
- new GifSequenceWriter( output, frames[0].image.getType(), frames[0].getDelay(), true );
+ new GifSequenceWriter(output, frames[0].image.getType(), frames[0].getDelay(), true);
- writer.writeToSequence( frames[0].image );
- for ( int i = 1; i < frames.length; i++ ) {
+ writer.writeToSequence(frames[0].image);
+ for (int i = 1; i < frames.length; i++) {
BufferedImage nextImage = frames[i].image;
- writer.writeToSequence( nextImage );
+ writer.writeToSequence(nextImage);
}
writer.close();