Resize image code does not work for some jpg files

Hello. I use the code to resize images and store them on the server below. However, with some jpg files, resizing produces a reddish tint on the picture. Any ideas of what could be the cause? Here's the original image: http://www.unctv.org/tWxkBbq_10M6wKRRL/PNCWWD01.jpg and here of what happened later: http://www.unctv.org/tWxkBbq_10M6wKRRL/PABDFC01__1289231445291.jpg
Photoshop CS5 is used to produce the input JPG for this app. thank you.
public BufferedImage resizeVeryHigh(InputStream inputStream, File resizedFile) throws IOException {
  BufferedImage bufferedImage = null;
  try {
      Image newImage = ImageIO.read(inputStream);
      int newWidth = (int)this.targetWidth;
      ImageIcon imageIcon = new ImageIcon(newImage);
      Image image = imageIcon.getImage();
      Image resizedImage = null;

      int iWidth = image.getWidth(null);
      int iHeight = image.getHeight(null);

      // This code ensures that all the pixels in the image are loaded.
      Image temp = new ImageIcon(resizedImage).getImage();

      // Create the buffered image.
      bufferedImage = new BufferedImage(temp.getWidth(null), temp.getHeight(null), BufferedImage.TYPE_INT_RGB);

      // Copy image to buffered image.
      Graphics g = bufferedImage.createGraphics();

      // Clear background and paint the image.
      g.setColor(Color.white);
      g.fillRect(0, 0, temp.getWidth(null), temp.getHeight(null));
      g.drawImage(temp, 0, 0, null);
      g.dispose();

      // Encodes image as a JPEG data stream
      FileOutputStream out = new FileOutputStream(resizedFile);
      JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
      JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bufferedImage);
      param.setQuality(1.0f, true);
      encoder.setJPEGEncodeParam(param);
      encoder.encode(bufferedImage);
  }
  catch (Exception e) {
        this.error = e.getMessage();
  }
      return bufferedImage;
}
Published by: oneworld95 on November 8, 2010 11:34

I don't know anything about the jpeg encoder, but I do not see the code which makes no sense to me:

Image resizedImage = null;

int iWidth = image.getWidth(null);
int iHeight = image.getHeight(null);

// This code ensures that all the pixels in the image are loaded.
Image temp = new ImageIcon(resizedImage).getImage();

What is so as to create an ImageIcon from an image zero?

int newWidth = (int)this.targetWidth;

I don't see where actually use you this variable, then how the image does get resized?

To learn more create a [url http://sscce.org] NBS, which illustrates the incorrect behavior and maybe someone will take a look.

Tags: Java

Similar Questions

  • A refurb Lenovo/IBM PC windows 7.0 SW, software code does not work for charging SW after a system restore

    A refurb Lenovo/IBM PC windows 7.0 SW, software code does not work for charging SW after a system restore. How can I get a new one

    Skip, enter the product key, and then complete the installation.

    Try the phone activation:

    How to activate Windows 7 manually (activate by phone)
     
    1) click Start and in the search for box type: slui.exe 4
     
    (2) press the ENTER"" key.
     
    (3) select your "country" in the list.
     
    (4) choose the option "activate phone".
     
    (5) stay on the phone (do not select/press all options) and wait for a person to help you with the activation.
     
    (6) explain your problem clearly to the support person.
     
    http://support.Microsoft.com/kb/950929/en-us

  • Items 11.  Resize image tool does not work.  I tried to chat online with Adobe - no help.

    I recently got a new computer (pc) and decided to download 11 elements instead of the old version that was on my old computer.   I discovered that the image resize tool does not work, even if the other functions seem to work well.

    I tried an online chat with Adobe.  Their suggestion was to buy another picture of them for $10 service. / month!

    You talk of Image > resize > Image size?

  • Sound does not work for some Web sites

    Hello

    I can't listen to music on the following Web sites:

    http://www.cede.ch/en/music/?branch_sub=1 & View = detail & ID = 896510 & Branch = 1
    http://estastonne.bandcamp.com/album/live-in-Odeon-2011

    I use the first a lot, which is really annoying. I've already looked and I think that the problem has to do with firefox. I have a linux system. When I try to play music, I see the time meter that works perfectly, the only problem is: I have no sound. If I install firefox 25, I have no problem. With firefox 26 or 27 of firefox it does not work. With the same configuration (plugins for example) if I switch to firefox 25, all right. I tried clearing the cache, but it does not help. I have no idea more.

    If anyone has an idea that would be great!

    Thank you

    This looks like a problem with the player player of the second site.

    I don't know what flavor of Linux, this thread is running, but there is a problem with GSStreamer around the time 25-27 that has been activated.

    I'm looking into this site and see player video javascript. The GSStreamer is used only with html5 and h.264 and others have their own codec.

    After some research on this second site, its an mp3 file. It's called TralbumData which is a hack for streaming music bandcamp. They use the MP3 format to 128 for data flow. http://Bandcamp.com/help/audio_basics There is also no volume control.

    So to answer your question, it seems to have been something that has stopped working. Please make sure that your media player is updated if you update to version 27.

    The bug for this specific page is https://bugzilla.mozilla.org/show_bug.cgi?id=921714 which recommend to disable media.gstreamer.enabled, in the subject: config as well.

    That should solve the problem!

  • "Sweep left" does not work for some email notifications

    On some mail notifications, as documented works "sweep left" very well, but I'm still not clear what if any difference there is between 'X' and 'Clear' (see previous announcement) - I have recently several contradictory theories.  However, for SOME e-mail notifications, "left sweep" simply does not work - nothing happens.  I * think * it's maybe for 'complex HTML' messages, not 100% sure.

    Hi Doug

    As previously indicated, 'X' and are clearly part of the same key - typing will erase / reject notification from your list of recorded notifications.

    Also as previously indicated, there is a difference between alerts by mail in the list of alerts in the Notification Center (IE hitting swiping to the left on the alert) compensation and removal / rampage messages in the Mail application.

    More information:

    https://help.Apple.com/watch/#/apddca457a4f

    https://help.Apple.com/watch/#/apd29461a7b7

  • Showcase (?) does not work for some sites.

    My problem is basically this: link text

    Some sites are listed, some are not. It's like to happen in a random order. I tried to clean the cache, it did not work.

    Any ideas?

    The pages that sends a non-magasin or no.-cache header are not cached and therefore Firefox does not generate a thumbnail.

    • bug 756881 - new thumbnails tab is displayed does not (or old images posted) for Facebook, Twitter (sites using Cache-Control non-magasin)

    (Please, don't comment in bug reports)

    You can check via the Web Console HTTP response headers (Web Developer > Web Console;) CTRL + SHIFT + K)

  • Present the online PDF form button does not work for some users

    Two online forms, I created in LiveCycle Designer 8.2 work very well for me. But when some of the users of my site clicking on the Submit button in a form, it just flashes and then does nothing. It's a standard transmission with a Mailto link button. The documents are PDF Version 1.7, and I use Acrobat Pro 9.4.5 and Reader 9.4. Suggestions for troubleshooting would be great.

    This form is activated with the form of rights to the player.  If the full PDF is presented, then the PDF file must be Reader enabled to operate the player.

    Another problem is that sending email is entirely dependent on the user's system.  There must be a local e-mail client installed and registered with the system.  Internet mail will not work.  This is the most likely issue.  Althougth there are other things that could be the problem.  You can consider using the Acrobat.com to distribute your forms.  This method gets around the question for most users.

    Other issues that could cause this problem are the version of Acrobat/Reader users as well as any type of system/security configuration funky.

  • CSS does not work for some reason any...

    Hello
    I use Dw MX and I use it back after having been there for a while. There are a couple of keys made here that may be important. First of all, I imported this site from Frontpage 2002 (it has been done initially in Frontpage 2003). Secondly, I am under Dw MX on Ubuntu Linux using CrossOver.

    So it is possible that this may be a problem of Linux, but it's a 50-50 as far as I know. In short, nothing that to do with CSS seems to work. I can't redefine a style Html - nothing appears. I tried to do and attach an external style sheet to get a picture in the background, and nothing is displayed. BTW, I do these especially for a model, but regular pages seem to have this problem as well.

    I can not even a background picture is displayed using the Page Properties.

    I am quite experienced with web programs; I did something like that for 6 years now. But here, I am puzzled, even if it is possible something in fair DW on me because it's been awhile. Also, I installed the MX 6.1 update.

    I appreciate any assistance.

    Thank you, Frank B.

    Murray, have you noticed:

    "First I imported this site.
    Frontpage 2002 (it has been done initially in Frontpage 2003). »

    It might be just stacking CSS rules at the top of the old rules of CSS, or even on top of
    HTML styles. It sounds like a code problem, not a problem of DW...

    --
    Patty Ayers | Adobe Community Expert
    www.WebDevBiz.com
    Free articles on the business of Web development
    Web Design contract, quote request form, estimate Worksheet
    --

    "Murray * AS *" wrote in message
    News:f6888a$3JL$1@forums. Macromedia.com...
    > Frank:
    >
    > Hmm - well, it means that the file system is not the problem. I don't
    > have much to do, as I don't remember the last time I saw someone
    > breaking in DW * nix on these cards...
    >
    > --
    > Murray - ICQ 71997575
    > Adobe Community Expert
    > (If you * MUST * write me, don't don't LAUGH when you do!)
    > ==================
    > http://www.dreamweavermx-templates.com - model of yard!
    > http://www.projectseven.com/go - DW FAQs, tutorials & resources
    > http://www.dwfaq.com - DW FAQs, tutorials & resources
    > http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
    > ==================
    >
    >
    > "brightbelt" wrote in message
    > news:[email protected]...
    > Yes, if I see a page with a link to another page in the same
    > site, the link works.
    >>
    > Thank you, Frank B.
    >
    >

  • Whitelist config.xml does not work for some AJAX calls

    Hello

    Here's an excerpt from my config.xml file:

    http://www. .TV"/ >

    Here is the error I get: http://cl.ly/image/3r420g1Q2b1F

    You have to trust me that the fields are the same (in the AJAX call and config.xml). Indeed, this app works fine on the browser BB10, but not "wrapped" with WebWorks.

    What is strange, is that several other AJAX calls to the same area as planned work. I don't know where to look what could be the problem?

    Thank you.

    So first of all, the reason for which the application is refused is due to a known issue with URI invalid containing @ signs. Technically the sign @ is only a valid uri character forward as [email protected]/blah, and at other points should be % encoded.

    By your work around, the good work around would be to allow access uri = "" * ", which should solve this case."

    By disabling the security web, shall be carried out as a last resort, but your original implementation was correct except for one minor detail, the value should be 'disable' and NOT 'disabled', thus


       

    Finally, you can still file a bug on github

    Hope this clears up things.

  • Family Pack with upgrade 3 license code does not work for Windows 7 Home Premium

    I bought Windows 7 Home Premium, with upgrade license 3 Family Pack.

    Yes, it is a genuine Microsoft product, bought at best buy original and worked fine on another PC.
    I tried to update one of my HP Pavilion yesterday which came with Windows Vista. Installation works well, but at the point where he asks me the license code, he says, it's the bad code and there is nothing I can do to go.
    Help, please.

    Skip entering your product key Windows 7 and complete the installation.

    When you reach the desktop, click Start, right-click on computer

    Click on properties

    Scroll down to the Windows Activation

    Click the link x days before activation.

    Click on the link that says: "show me other ways to activate.

    Enter the product key

    Click next

    Select the Activation of the phone

    Click Next when you enter your key page

    Select your country

    Click Next, call the number listed

    Be sure to explain your situation to the Appeals Officer.

    Provide the installation generated when ID requested by the call agent

    They give a confirmation ID in return, enter it

    Click next to complete the activation.

    However, the requirements for the media upgrade is that you have an operating system already eligible such as Windows XP or Vista installed to use it. Since the Windows 7 end user license agreement.

    15 UPDATES. To use upgrade software, you must first be licensed for the software that is eligible for the upgrade. After the upgrade, this agreement takes the place of the agreement for the software that you upgraded. After upgrade, you can no longer use the software that you upgraded.

    So, if you are always denied, you will just have to reinstall Windows XP or Vista and let it do the verification of eligibility.

    or

    How to activate Windows 7 manually (activate by phone)
     
    1) click Start and in the search for box type: slui.exe 4
     
    (2) press the ENTER"" key.
     
    (3) select your "country" in the list.
     
    (4) choose the option "activate phone".
     
    (5) stay on the phone (do not select/press all options) and wait for a person to help you with the activation.
     
    (6) explain your problem clearly to the support person.
     
    http://support.Microsoft.com/kb/950929/en-us

  • First broadcast 13 video clips fade out does not work for some clips, why?

    Operating system is Windows 10. Usually succeeds first items 13.1 video melted on accessible by right-clicking on a clip. But in some cases, nothing happens. In these cases, I managed to falter by using Transitions--> chained, but lacks the ability to use Bezier. What could be the reason?

    Ferro1945

    First elements 13/13.1 on Windows 10 (supposed 64 bit)...

    What are the properties of these clips for which "in some cases, nothing happens?

    You ask the bland as shortcuts or route of the applied effects tab?

    And, did you apply other effects to these clips before making the bland? Like Time Stretch?

    Please read the following should apply to more than 11.

    First Elements ATR troubleshooting: PE11: Timeline Fade Out shortcuts and stretched / remappe time video

    It is a long and detailed article. The Introduction summarizes the situation.

    If please consider and let us know the result, as your time permits.

    Thank you.

    RTA

  • Hi my iphone 5s does not work for some sacurity reasons that I can use the serial number or imei

    My iphome for sacurityureasonscan disable I reset serial number or imei/5 s

    account disabled for security reasons: http://support.apple.com/en-us/TS2446

  • The research of the embedded index does not work for the PDF file opened with Adobe Reader in a browser

    Due to the way in which we use our Document management system, if we want to search through multiple or large files stored in our DMS PDF we merge PDF together and create an embedded index. This works perfectly well, when you open the PDF file in Adobe Reader standalone. Enter a particular term can bring 100 hits (very quickly) in the Adobe Reader search results pane.

    However, if we launch the PDF with Adobe Reader in Internet Explorer (any version), enter a term to search (contained in document) only get one result, that of the file name of the document itself.

    Unfortunately most of our users will access our DMS documents with internal links.

    Any ideas greatly appreciated.

    K

    It is a problem with Reader 8. You must use that...

    Using Reader 9. It will work well with it.

    -Arnav Agarwal

  • I installed the German version of Photoshop, now I need the version in English for some actions, that I bought. In Photoshop preferences is German and I can't change to English. I changed my Creativ cloud in English, but does not work for Photoshop. I do

    I installed the German version of Photoshop, now I need the version in English for some actions, that I bought. In Photoshop preferences is German and I can't change to English. I changed my Creativ cloud in English, but does not work for Photoshop. What do I need to reinstall Photoshop in English?

    Also if you wish, you can take back to the top of Presets, plugins... before uninstalling.

  • Why my license code does not work on lightroom 6 for mac?

    Why my license code does not work on lightroom 6 for mac? My os x is "el capitan".

    Please try the steps to serialize Lightroom CC trial to activate like Lightroom 6 mentioned on: https://helpx.adobe.com/lightroom/kb/serialize-lightroom-cc-trial-to-activate-as-lightroom - 6.html

    You can also try: error "serial number is not valid for this product". Creative Suite

Maybe you are looking for