Question concerning writing image as JPG using imageio

T

Trung Chinh Nguyen

Here's the code that I'm using:

Iterator writers = ImageIO.getImageWritersByFormatName("jpg");
ImageWriter writer = (ImageWriter)writers.next();
ImageOutputStream ios = ImageIO.createImageOutputStream(new
File(outputFile));
writer.setOutput(ios);
writer.write(outputImage);

I'm wondering about the quality of the output image (i.e how much data
is lost), and is there a way to change it?
 
S

steve

Here's the code that I'm using:

Iterator writers = ImageIO.getImageWritersByFormatName("jpg");
ImageWriter writer = (ImageWriter)writers.next();
ImageOutputStream ios = ImageIO.createImageOutputStream(new
File(outputFile));
writer.setOutput(ios);
writer.write(outputImage);

I'm wondering about the quality of the output image (i.e how much data
is lost), and is there a way to change it?

this is java , what do you think?

have a look at:


JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(os);
JPEGEncodeParam param =
encoder.getDefaultJPEGEncodeParam(outImage);

param.setQuality((float) .9, false);
encoder.setJPEGEncodeParam(param);
encoder.encode(outImage);

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top