TFS operation pictures, and small pictures
After tfs is saved, it will return a new file name (which can be controlled as the original file name), and then it is obtained through this file name. All files passed to and stored in tfs are in a default root folder, and all files are checked through the hash index, we save database
You can splice some virtual business roads
The example includes, save into tfs, and save the thumbnail in tfs
public static String lessImageTfs(String inPath, String outPath, int times)
{
boolean flag = true;
String name="";
try
{
OutputStream o=TFSUtil.getTfsFile(inPath);
ByteArrayOutputStream oo= new ByteArrayOutputStream();
ByteArrayOutputStream output = (ByteArrayOutputStream) o; //OutputStream 转为InputStream
byte[] data = output.toByteArray();
ByteArrayInputStream input = new ByteArrayInputStream(data);
// BufferedImage image = ImageIO.read(input);
BufferedImage bufferedImage = ImageIO.read(input);
bufferedImage = lessImage(bufferedImage, times);
name= TFSUtil.saveTfsByteFile(output.toByteArray(), outPath);
}
catch (Exception e)
{
e.printStackTrace ();
return "";
}
return name;
}
public static BufferedImage lessImage(BufferedImage bufferedImage, int times)
throws Exception
{
int height = bufferedImage.getHeight() / times;
int width = bufferedImage.getWidth() / times;
BufferedImage newBufferedImage = new BufferedImage(width, height, bufferedImage.getType());
Graphics g = newBufferedImage.getGraphics();
g.drawImage(bufferedImage, 0, 0, width, height, null);
g.dispose();
return newBufferedImage;
}