Results 1 to 2 of 2
  1. #1
    ScottVal is offline Member
    Join Date
    Jan 2009
    Rep Power

    Default Creating a jpeg file: "no preview available"

    When I create a jpeg file within a java program, and then (I'm using Windows) go to look at it, I can see it just fine with the thumbnail in my Windows folder, but if I open the file with the Windows Picture and Fax Viewer, it says "no preview available," and doesn't display the image.

    Here's my code:

    Iterator iter = ImageIO.getImageWritersByFormatName("jpeg");
    ImageWriter writer = (ImageWriter);

    // instantiate an ImageWriteParam object with default compression options
    ImageWriteParam iwp = writer.getDefaultWriteParam();

    iwp.setCompressionMode(ImageWriteParam.MODE_EXPLIC IT);
    iwp.setCompressionQuality(1); // an integer between 0 and 1
    // 1 specifies minimum compression and maximum quality

    FileImageOutputStream output = new FileImageOutputStream(file);
    IIOImage im = new IIOImage(image, null, null);
    writer.write(null, im, iwp);
    writer = (ImageWriter); // Force closing of the writer

    Btw, I get an exception on that last line (the "next" call), NoSuchElementException. Maybe it's related?


  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Rep Power


    I would guess you should close the writer.

    Why don't you search the web for examples. You know the method names you are trying to use, so use the method names as keywords and see what you find.

Similar Threads

  1. Replies: 6
    Last Post: 02-10-2011, 10:55 AM
  2. "endless" eventLoop when creating new Instance
    By javacafe in forum Eclipse
    Replies: 0
    Last Post: 08-10-2009, 06:37 PM
  3. Replies: 2
    Last Post: 01-24-2009, 07:56 PM
  4. Replies: 0
    Last Post: 11-22-2008, 02:49 AM
  5. Replies: 1
    Last Post: 10-20-2008, 07:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts