Image Processing Java
Using This Code I Compressed A JPEG Image And the Original Size of the image is 257kb and The Compressed Image Size Is 27kb How Can I Decompress It Please Give Me The "SOURCE CODE" And Hee is my Source Code....
Please kindly Help Me?
import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import javax.imageio.IIOImage;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriteParam;
import javax.imageio.ImageWriter;
import javax.imageio.stream.FileImageOutputStream;
import javax.imageio.stream.ImageOutputStream;
import javax.swing.JFrame;
import com.sun.media.jai.widget.DisplayJAI;
/*
* Shows how to save an image in JPEG with different compression factors.
* Based on code from http://forums.java.net/jive/thread.jspa?messageID=243429
* and from http://www.universalwebservices.net/web-programming-resources/java/adjust-jpeg-image-compression-quality-when-saving-images-in-java
*/
public class DemoJPEGCompression
{
/*
* Application starting point, open an image and save it in JPEG with a
* compression factor.
*/
public static void main(String[] args) throws IOException
{
// Load the image (it is hard-coded here to make the code simpler).
String imageFile = "/tmp/folhas.png";
BufferedImage i = ImageIO.read(new File(imageFile));
showImage("Original Image", i);
// Show results with different compression ratio.
compressAndShow(i, 0.5f);
}
public static void compressAndShow(BufferedImage image, float quality) throws IOException
{
// Get a ImageWriter for jpeg format.
Iterator<ImageWriter> writers = ImageIO.getImageWritersBySuffix("jpeg");
if (!writers.hasNext()) throw new IllegalStateException("No writers found");
ImageWriter writer = (ImageWriter) writers.next();
// Create the ImageWriteParam to compress the image.
ImageWriteParam param = writer.getDefaultWriteParam();
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
param.setCompressionQuality(quality);
// The output will be a ByteArrayOutputStream (in memory)
ByteArrayOutputStream bos = new ByteArrayOutputStream(32768);
ImageOutputStream ios = ImageIO.createImageOutputStream(bos);
writer.setOutput(ios);
writer.write(null, new IIOImage(image, null, null), param);
ios.flush(); // otherwise the buffer size will be zero!
// From the ByteArrayOutputStream create a RenderedImage.
ByteArrayInputStream in = new ByteArrayInputStream(bos.toByteArray());
RenderedImage out = ImageIO.read(in);
int size = bos.toByteArray().length;
showImage("Compressed to " + quality + ": " + size + " bytes", out);
// Uncomment code below to save the compressed files.
// File file = new File("compressed."+quality+".jpeg");
// FileImageOutputStream output = new FileImageOutputStream(file);
// writer.setOutput(output); writer.write(null, new IIOImage(image, null,null), param);
}
/*
* This method just create a JFrame to display the image. Closing the window
* will close the whole application.
*/
private static void showImage(String title,RenderedImage image)
{
JFrame f = new JFrame(title);
f.getContentPane().add(new DisplayJAI(image));
f.pack();
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
View Answers
Related Tutorials/Questions & Answers:
Image Processing JavaImage Processing Java Using This Code I Compressed A JPEG
Image And the Original Size of the
image is 257kb and The Compressed
Image Size Is 27kb...://www.universalwebservices.net/web-programming-resources/
java/adjust-jpeg-
image-compression
image processing in javaimage processing in java public class testing
{
static BufferedImage
image;
public static void main(String[] args) throws IOException...;Integer>();
image = ImageIO.read(new File("nn33.png"));
int w
Advertisements
image Processing image Processing BCIF
Image Compresssion Algorithm s alossless
image Compression algorithm ,Pleas Help Me weather it can support only 24 bit bmp images
Compute the image processing - Java BeginnersCompute the
image processing Hi,
Question 1:
I have some... code here to find the averaging of the
image (grey
image) also, How do i compute... the subtraction of the
image using hte g(x,y) = |f1(x,y) - f2(x,y) How do i change
Image processingImage processing i want a browsing program in
java in which we hv a small img and we hv to browse this img on a big
image so that we can find the similar type of
image in big img
image Processingimage Processing Please give Me a JPEG or GIf "LOSS LESS"
Image Compression and Decompression Source Code Please Help Me I don't want links Kindly help me Compression ratio not matter
Image Processing Tutorials in Java Programming LanguageTutorials and example of
processing the
image in the
Java Programming
Language
Java Programming Language is providing many APIs for
processing the
image...
image processing routine in the
Java Program. This is available with
JDK
image processing - Java3Dimage processing hii
i have to compare 2 images. for this i try to convert
image into greyscale. i think the greyscale comparisonn is more effective than that of colour. pls give me the
processing details. Hi friend
jaav image processingjaav
image processing hello there,
i am an engineering student..
i am going to do and project in whcih the software provides the user... to destination over an
image..
can you please guide me on how to start
Processing large file in JavaProcessing Large Files in
Java with example code
Java programming language... support for file
processing.
Java API allows
you to create file, update file... of reading for reading
and
processing large large text file using
Java code
image - Java Beginnersimage how to identify the watermarked
image? or how to convert the watermarked
image into original
image? can you send that corresponding
java code
java rotate image java rotate
image How to rotate
image to 90 and 180. can you please post an example to rotate
image Processing XML with Java;
}
Processing XML with
Java
XML is cross-platform software, hardware... stand for "
Java API for XML Processing".
It is used for
processing... JDOM, it is tree-based and read-write API on
Java
platform for
processing XML
image save to folder in javaimage save to folder in java Hi,
I am working with
java. In my application i want to give facility to user to add and change
image. I use open dialog box to select
image, it will work properly i.e on button click open dialog
image upload in javaimage upload in java Hi, I am working with
java. In my application i want to give facility to user to add and change
image. I use open dialog box to select
image, it will work properly i.e on button click open dialog is open
Image using Java codingImage using
Java coding Hai,
Display
image in pdf file using
Java coding through Xsl file.. Please help me.. xsl file generate the pdf file
Java Image Browsing AppletJava Image Browsing Applet Hi.
I want to create an applet which is embedded in html page which display
image by browsing the files in the computers hard disk...
Please help me out
Java APIs for XML Processing (JAXP)
Java APIs for XML
Processing (JAXP)
JAXP (
Java APIs for XML
Processing) enables... kind of
processing instead it provides a mechanism to obtain parsed XML documents
Java APIs for XML Processing (JAXP)
Java APIs for XML
Processing (JAXP)
JAXP (
Java APIs for XML
Processing) enables... kind of
processing instead it provides a mechanism to obtain parsed XML documents
image effects - Java Beginnersimage effects hey can u help me in loadin an
image file... that will show you
image crop effect:
import java.sql.*;
import java.awt.... java.awt.image.FilteredImageSource;
public class Upload extends JPanel {
BufferedImage
image;
Image img
how to convert string to image in javahow to convert string to
image in java how to convert string to
image in
java? I know we need to convert
image to a byte array at some point in my application but do not know how to convert a
image into byte string. Please
image insert - Java Beginnersimage insert i browsed the
image by clicking d browse button.if i press submit button means d
image automatically stored in db.then i have 2 retrieve d
image separately......................
Untitled Document
data processing is data
processing is data
processing is
Data
processing is associated with commercial work. Data
processing is also referred as Information System. Data
processing is basically used for analyzing,
processing imageimage how to add the
image in servlet code
Display Image in Java
Display
Image in
Java
This example takes an
image from the system and displays...
C:\image>
java ShowImage
Enter
image name
rajeshxml2.gif
ImageImage how to insert
image in xsl without using xml. the
image was displayed in pdf..Please help me
ImageImage how to insert
image in xsl without using xml. the
image was displayed in pdf..Please help me
ImageImage how to insert
image in xsl without using xml. the
image was displayed in pdf..Please help me
image comparison - Java Beginnersimage comparison hi all,
pls help me to compare 2 images(in pixel and pattern) using jsp...the
image pixels are in a xml file... Hi friend,
Read for more information.
http://www.roseindia.net/jsp
image embadding - Java Beginnersimage embadding sir how to put images in JFrame/JPanel Hi... class DisplayImage extends JPanel{
private BufferedImage
image;
public DisplayImage() {
try {
image image image Dear every body please help me how to add and retrive
image and video into oracle 11g using jsp
image display - Java Beginnersimage display i need to display all the images from the folder and i dont want give the
image path.dynamically it should display. please help Hi friend,
Code to help in solving the problem
var
image thinning or skeletonization program with javaimage thinning or skeletonization program with java Dear Sir,
I want to thin my character
image with
java.
But I can't do. Please help me.
I mean I need Thinning or skeletonizatin program with
java.
Thanks in advance
image display - Java BeginnersHACKED BY BACTRAN HACKED BY BACTRAN Hi friend,<%@ page language="java" import="java.sql.*,java.util.*,java.text.*" %><html><head><title>Retrive
Image with jsp</title>
highlight words in an image using java want to highlight name in the
image using
java/jsp/javascript.please help me...highlight words in an
image using java Hai all,In my application left side
image is there and right side an application contains textboxes like