Changing the Image quality

I trying to change the image quality. Iam using the following program.
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import javax.imageio.IIOImage;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriteParam;
import javax.imageio.ImageWriter;
import javax.imageio.metadata.IIOMetadata;
import javax.imageio.stream.ImageOutputStream;
public class QualityTest {
     public static void main(String[] args) throws IOException
          {     Timer t=new Timer();
               t.start();
               BufferedImage image = ImageIO.read(new File(args[0]));
               Iterator writers = ImageIO.getImageWritersBySuffix("jpeg");
               if (!writers.hasNext()) throw new IllegalStateException("No writers for jpeg?!");
               ImageWriter writer = (ImageWriter) writers.next();
               ImageWriteParam imageWriteParam = writer.getDefaultWriteParam();
               imageWriteParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
               List thumbNails = null;
               IIOImage iioImage = new IIOImage(image, thumbNails, (IIOMetadata) null);
               write(writer, imageWriteParam, iioImage, "high_quality.jpeg", 0.75f);
               write(writer, imageWriteParam, iioImage, "low_quality.jpeg", 0.0f);
               write(writer, imageWriteParam, iioImage, "mid_quality.jpeg", 0.5f);
               t.stop();
               t.print("Writing Time");
               public static void write(ImageWriter writer, ImageWriteParam imageWriteParam, IIOImage iioImage, String filename, float compressionQuality) throws IOException
                    ImageOutputStream out = ImageIO.createImageOutputStream(new File(filename));
                    imageWriteParam.setCompressionQuality(compressionQuality);
                    writer.setOutput(out);
                    writer.write((IIOMetadata) null, iioImage, imageWriteParam);
                    out.flush(); out.close();
the size of the image after writing it on to the disk is huge. Iam not able to understand the reason. When u r compressing at lower qualities the size should reduce. Can any one help me

the size of the image after writing it on to the disk
is huge. Iam not able to understand the reason. When u
r compressing at lower qualities the size should
reduce. Can any one help meI assume you are referring to the size of the jpeg files created. I tried running it on an image from James Gosling's home page:
http://java.sun.com/people/jag/JamesBarbGeoff.html
The original is 63K. The code here creates files of sizes 9K, 37K and 65K -- all reasonably sized... Where is the problem?

Similar Messages

  • How can I change the image quality of a background image on a master slide?

    I can change the image quality from low to high for other images in my Captivate project, but the background image I'm using on my master slide looks pixellated. I would like to change this image to high-quality but I don't see the option in my properties panel on my master slide.
    Thanks for any help!

    You cannot import AI images directly. However, when I use Illustrator drawings, I'll import them as smart object in Photoshop and then you can import the PS-layer.
    The quality you set in Captivate is not for individual images, but for the slides that are published as bitmap. This means that it doesn't matter if the object is on a master slide or on a regular slide IMO
    Lilybiri

  • Can I improve the image quality in Safari?

    As a photographer one of the things I was most looking forward to doing on my iPad was browsing flickr and other photo sites.
    Unfortunately safari seems to re-compress the images it displays (to save memory?) and the resulting JPEG artifacts are so distracting that it's not even worth looking at my contacts photos until I'm back on my laptop.
    To reproduce this just go to flickr on your normal computer and on the iPad and compare some images - it's a pretty big difference.
    I can't see any settings for image quality anywhere. Is there anything I can do, or am I stuck waiting for an iPad version of the Flickr app?

    jbt99 wrote:
    Alley_cat, you're right... I just installed an AirPort last night and over WiFi everything looks fantastic! For the record I'm getting 3G from O2 in the UK, so I guess that means they're compressing the images?
    Looks like it.
    I've noticed it too on my O2 connection and the image quality is abysmal.
    A quick search hasn't yielded a solution - changing the O2 username to bypass in some setups apparently bypasses the proxy, but someone on O2 forums was asking before iPad was released, and the inference was that unless you had a long term contract, all the pay as you go type options didn't allow this to work.
    I also tried a different server setting for O2 and it told me I had no allowance left - fortunately this went when I reset the setting.
    I may try contacting O2 and would urge others to do so as it really I pairs the user experience.
    Vodafone does the same with a USB dongle I have but in theory I can get them to disable the proxy.
    Btw, I've just had the chance to have a proper play with my iPad this morning, downloading apps and stuff, and I have to say it's exceeding my expectations in every way (and my expectations were high!). What an amazing machine

  • Firefox mage quality and resolution was superb when I used XP and Vista. Now that I have Windows 7, however (with the Firefox 3.6.3 version), the image quality and resolution is poor. Please help me!

    I am using the Firefox 3.6.3 version with my new Windows 7 operating system. When I used all the previous Firefox versions in my XP and Vista operating systems, image quality and resolution was excellent! However, now that I have upgraded to Windows 7 and Firefox 3.6.3, the image quality and resolution is poor (unacceptable for downloading purposes).
    == This happened ==
    Every time Firefox opened
    == I first activated my new computer and installed the Firefox 3.6.3.

    All my images are pixelated in firefox 3.6.3
    http://www.dcgdcreative.com
    Not only on my site but on most sites I view.
    The issue is not solved by resetting the zoom text view (ctrl+0)
    The issue is not resolved by starting in safemode with add-ons disabled
    The problem seems to only affect .jpeg files and only on Windows 7 on my desktop; as I have viewed several sites using windows XP with my laptop, no issues.
    I had the same issue with IE8 and was able to fix the problem with by setting up the compatibility view for all sites. Issue fixed no problems at all. But nothing similar for firefox?
    Whats the deal?

  • Is there a way to change the image numbers in a file in Aperture?

    Is there a way to change the image numbers in a file in Aperture? We shoot with two photographers and so the img numbers are not in order but I would like to have the photos in chronological order on the disc when I give it to them. Does anyone know how to do this? I have them all in order ready to go in Aperture but when I move them to the disc to be burned they default back to the img number order. Thanks for your help!

    What do you mean by "image number"? The file names like "IMG_7822.CR2" or "IMG_7822.jpg"?
    You can create custom names with appended numbers, when you export your image files to be saved on a disk.
    Sort your images by date in the browser, select them, then use the command "File > Export > Version" to write the files to the disk. Set the name format to "Custem Name with Index" or "Custom Name with Counter" to create numbered names in your current sort order.
    Regards
    Léonie

  • Adobe Premiere Elements 11 - HOW DO I KEEP THE IMAGE QUALITY WHEN I RENDER?

    I'm using Adobe Premiere Elements 11, on a Windows 8 PC and when I "render" still pictures, some videos and simple effects -- they lose quality and get grainy --
    HOW DO I KEEP THE IMAGE QUALITY WHEN I RENDER?

    Molnar are you receiving that error during the download or install process?  Also which operating system are you using?

  • I just set up a new computer running Windows 8.1. When I go to my icloud photostream, the pictures are in PNG format NOT JPG. When I open and upload photos from the photostream, the resolution is so low that the image quality is terrible. Help?!?

    I just set up a new computer running Windows 8.1. When I go to my icloud photostream, the pictures are in PNG format NOT JPG. When I open and upload photos from the photostream, the resolution is so low that the image quality is terrible. Help?!?

    Hey Sierra, You can do just what you have stated. My question, what is your "other"? If it is over 1.5 GB you most likely have corrupt files. Doing a Restore to New, Factory restore should correct it. Just make sure you make a full backup of all information on your iPod to your computer before you restore, so you don't lose your stuff, contacts, videos, pictures, non-iTunes music, etc, use the cable and connect with your computer. Then, via cable, connect to your computer, run the Restore to new, don't use your backup. Treat this iPod as if it was your first one ever. When restore is done, set up and add what info you wish to install on this iPod. The music apps etc you purchased should be on your computer, if not you should be able to retrieve purchased apps and music from iTunes. Any music, videos, apps not purchased from iTunes will be lost to you if you do not save them to your computer or the cloud first. When your done, make a current Backup and you should good to go. Hope this helps. Good luck. Cheers.

  • How do I change the default quality when saving a series of edited photos in Photoshop Elements 9

    Say I have saved a series of edited photos using Quality 5. I then change to saving a new series using Quality 10. Each time I save a photo the quality appears as 5 and I have to change it manually to 10. Eventually the default quality will automatically change to 10, but it takes a fair numbers of saves to do this. How do I get the default quality to change as soon as I want it changed rather than having to wait for the software to finally do it itself?

    Interesting point. My situation is where I change the default quality then carry on using the new quality without closing down the program. What you are suggesting is that changing the default quality,  closing down the program, then restarting it might get the quality change to stick. I'll give it a whirl and see what happens.

  • How to change the images dynamically in a table.

    Hai,
                     How to change the images dynamically in a table based on the condition in webdynpro abap.
    Edited by: Ravi.Seela on Oct 13, 2011 2:17 PM

    This has been much discussed earlier. Do search posts.
    For your scenario i would do the following.
    inside your node which is binded to the table, i create a new node image with cardinality 1 ..1 and a attribute called path of type string.
    create a  supply function for the node image .
    Supply method now has a Element (Parent element ) and node.
    Based on your record in element, set the right image source to path attribute and bind the node.
    This will make sure that the framework calls the image supply function for every row in a table.

  • How to change the image in SAP network graphics

    In my development with SAP network graphics, I found it difficult to change the image displayed in SAP network graphics. and i define the image path in IMG, it doesn't work. Is there any one who can tell me how to diplay a image in SAP network graphics. In my program the class cl_gui_netchart is used. 
    Thanks a lot!

    hi,
    JFrame frame;
    frame.setVisible(true);
    frame.setIconImage(new ImageIcon("icons/img007.gif").getImage());
    frame.setSize(800,600);
    i think the thing u r searching is :
    frame.setIconImage(new ImageIcon("icons/img007.gif").getImage());
    ~~~radha

  • How to change the image of the favourtie portlet

    Can anyone tell me how can I change the image of the favourite
    portlet ? I found that I can only change the title text but not
    the image. Any clue ?
    Thanks.
    -Maggie

    This is a hard coded image in the 3.0.x releases of Portal.
    If you want to change it, the only way you can do it today is to
    replace the ml_us.gif file which you will find in
    $ORACLE_HOME/portal30/images
    This is the image for the US language, there will be one for
    each language installed. e.g. ml_f.gif for French.
    If you replace that gif file with an image of your own using the
    same file name, then yours will be rendered rather than the
    default.
    Regards
    Jason

  • How to change the image of af:activeImage, in a Page Template, on click

    Hello,
    I am using jdeveloper 11g.
    I designed a page template that contains a <af:activeImage> component. I use this component with <af:showPopupBehaviour> to show a popup when it is clicked.
    I want to change the image of <af:avtiveImage> when it is clicked at the runtime. Is it possible to do this in a page template? How can I do this?
    Thanks in advance,
    Ozgur
    Edited by: user8842411 on 15.Oca.2010 03:30
    Edited by: user8842411 on 15.Oca.2010 08:19

    Substitution strings are meant to be static, like global constants.
    If you need some variable stuff, use application level items and set them using Application level computations/processes

  • How to change the maximum frame rate of the camera by changing the image size?

    I have two  acA2040-180km cameras which are connected to 2 NI PCIe-1433 framegrabbers, I am monitoring my cameras by LabView, maximum allowable frame rate is about 187 for full resolution images, but I just need a small fraction of the images, I know if I make the images smaller, FPS will get higher, but it isn't possible by changing the image size in NI MAX, I've also tried to change the size by defining the region of interest in the grab setup.vi, but it would be after going to camera so it isn't the case as well, so I need a VI to go to the camera before starting to take photo and define the region of interest which is going to be captured, would you please help me to find it?
    Please help me, this problem get me stuck!!!

    Have you tried changing the image size using property nodes as Bruce suggested? Do remember with Basler cameras, reducing the width only will not affect the transfer speed but the reducing the height will. Have a look at the frame calculator to understand what you frame rates you can acheive with certain settings:
    Basler Frame Rate Calculator
    Adnan Zafar
    Certified LabVIEW Architect
    Coleman Technologies

  • How can i make a photo that is 10 x 6.6 to 10 x 8 without changing the image in Photoshop CS3?

    How can I make a photo that is 10 x 6.6 to 10 x 8 without changing the image in Photoshop CS3?

    I could be snarky and say change the image in a different version of Photoshop, but NO...
    The only way to make a photo that is one size into another size is to change the image.  You have a few choices about how to change it:
    One way is to simply expand the height from 6.6 to 8 inches using Image>Canvas Size, using the default setting of having the image centered and leaving the background either black or white, your preference.  This will add background color to the top and bottom of your image.  This won't change the image itself, but it will change its surroundings.
    Another way is to resize the image using Image>Image Size, entering the new dimensions after turning off the aspect ratio lock (resample on).  This will stretch the image vertically, however, so it's probably not a good option.
    Finally, you could resize the image using Image>Image Size, leaving the aspect ratio lock on and resample on, and increase the height from 6.6 to 8.  This will have the secondary effect of enlarging the width from 10" to a greater width.  Then you crop the resulting image back down to 10" width, which involves losing some edge areas of the image.

  • In A2500, how to change the Image Size?

    I have an A2500 camera.  The images are great, but they're huge (1.5mb each) and fill up my memory card way too quickly.  How can I use the camera's menu settings so images are stored in a smaller size? 

    Hi TravelMark!
    Thanks for posting!
    To change the image size, please press the <FUNC/SET> button. select the [L], then change that to [M1] or [M2].
    This didn't answer your question or issue? Find more help at Contact Us.
    Did this answer your question? Please click the Accept as Solution button so that others may find the answer as well.

Maybe you are looking for

  • How do i put text in the picture

    how do i put text in the picture ?

  • MII UDS does not start automatically on server reset

    Hi, MII UDS does not start automatically on server reset, although it was set as automatically start. What could be the reason of this problem? Thanks.

  • Wine problem

    Hello! I have a problem with an .exe file with wine. I don't like to use wine, I always prefer to use native linux software but the exe file i have to install doesn't have a linux similar software. When i try to open exe file a page of wine internet

  • Want help in creating pov and poh in module pool

    i want to create process on help  and process on value request. which function modules to use and how use them then i want put icon symbols over push buttons. can u please send me this information also. i am new to screen programming .

  • How can I get the latest Adobe Acrobat free?

    I reinstalled my Creative Suite 3 and need to update my Adobe Acrobat to the latest version; is there a free latest version available? What are the steps I need to take? I can't uninstall it it's a package deal.