Question concerning writing image as JPG using imageio

Discussion in 'Java' started by Trung Chinh Nguyen, Apr 25, 2006.

  1. 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?
     
    Trung Chinh Nguyen, Apr 25, 2006
    #1
    1. Advertising

  2. Trung Chinh Nguyen

    steve Guest

    On Tue, 25 Apr 2006 21:38:26 +0800, Trung Chinh Nguyen wrote
    (in article <mDp3g.24017$>):

    > 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

    --
    NewsGuy.Com 30Gb $9.95 Carry Forward and On Demand Bandwidth
     
    steve, Apr 25, 2006
    #2
    1. Advertising

  3. Thanks for your answer, this is exactly what I'm looking for :)

    steve wrote:
    >
    > 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
    >
     
    Trung Chinh Nguyen, Apr 26, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. F C
    Replies:
    2
    Views:
    5,176
  2. Patrick
    Replies:
    1
    Views:
    740
  3. Davidski
    Replies:
    0
    Views:
    3,911
    Davidski
    Nov 5, 2004
  4. Rune
    Replies:
    4
    Views:
    1,865
  5. Replies:
    3
    Views:
    21,490
    Knute Johnson
    Nov 18, 2005
Loading...

Share This Page