First of all you need bmp image file format this file in your java file folder . Image file name is input and after the run compress.java then automatically generate.bmp Then you check file size is very small compare to input size file. This is java code for compresses windows BMP image file. import java.awt.image.BufferedImage; import java.io.*; import java.util.Iterator; import javax.imageio.*; import javax.imageio.stream.*; public class compress { public static void main(String[] args) throws IOException { File input = new File("input.bmp"); BufferedImage image = ImageIO.read(input); File compressedImageFile = new File("generate.bmp"); OutputStream os = new FileOutputStream(compressedImageFile); Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); ImageWriter writer = (ImageWrite...
Comments
Post a Comment