19-12-2012, 06:36 PM
IMAGE COMPRESSION
IMAGE COMPRESSION.docx (Size: 12.29 KB / Downloads: 22)
Algorithm:
1. Declare the required variables
2. Get input image file in Fin and print the output
3. The image file is stored in another folder
4. Check the condition for storage level
5. Print the memory of our folder before and after the addition of image
6. Halt the program.
PROGRAM:
import java.io.*;
import java.net.*;
import java.util.zip.*;
class dzip
{
Public static void main(String z[]) throws Exception
{
FileInputStream Fin=new FileInputStream(“sunset.jpg”);
DeflaterOutputStream dout=new DeflaterOutputStream(new FileOutputStream(“sunset.zip”);
int b;
while((b=Fin.read())!=-1)
dout.write(b);
Fin.close();
Dout.close();
File f1=new File(“sunset.jpg”);
File f2=new File(“sunset.zip”);
System.out.println(“BEFORE:”+f1.length());
System.out.println(“AFTER:”+f2.length());
}
}