How to generate thumbnails automatically by Java
This article mainly introduces the relevant knowledge of "how to automatically generate thumbnail pictures in Java". The editor shows you the operation process through an actual case. The method of operation is simple and fast, and it is practical. I hope that this article "how to automatically generate thumbnail pictures in Java" can help you solve the problem.
First, the method of automatically generating thumbnails:
Package writeimg; import java.awt.geom.AffineTransform;import java.awt.image.AffineTransformOp;import java.awt.image.BufferedImage;import java.io.File;import java.io.IOException;import javax.imageio.ImageIO; public class JpegTool {private boolean isInitFlag = false; / / whether the object has been initialized private String pic_big_pathfilename = null; / / defines the file name of the path directory where the source picture is located private String pic_small_pathfilename = null / / the file name of the directory with the storage path for generating small images is private int smallpicwidth = 0; / / define the width and height of the generated small images, and give it one: private int smallpicheight = 0; private int pic_big_width=0; private int pic_big_height=0; private double picscale = 0 / / define the ratio of a small picture to the original image / * constructor * @ param has no parameter * / public JpegTool () {this.isInitFlag = false } / * private function, reset all parameters * @ param no parameters * @ return no return parameters * / private void resetJpegToolParams () {this.picscale = 0; this.smallpicwidth = 0; this.smallpicheight = 0 This.isInitFlag = false;} / * * @ param scale sets the size ratio of the thumbnail image to the source image, such as 0.5 * @ throws JpegToolException * / public void SetScale (double scale) throws JpegToolException {if (scale)