Jpeg encoding with imageio - pink distortion problem

Hello, I am using the imageio classes to scale down jpg images (for thumbnails) and write them to a file. On most images, everything works perfectly. On some images, however, the resulting thumbnail image has a strange pink coloration to the whole picture. Does anyone have any ideas as to why this would happen? The code I am using is below. I thank anyone that takes the time to read this and hope someone can help.
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.awt.image.IndexColorModel;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.imageio.IIOImage;
import javax.imageio.ImageIO;
import javax.imageio.ImageTypeSpecifier;
import javax.imageio.ImageWriteParam;
import javax.imageio.ImageWriter;
import javax.imageio.plugins.jpeg.JPEGImageWriteParam;
import javax.imageio.stream.ImageOutputStream;
public class ImageResizer
     private static final int THUMBNAIL_MAX = 120;
     private static final int SMALL_MAX = 250;
     private static final int LARGE_MAX = 575;
     private static final int LARGE_THRESHOLD = 425;
     BufferedImage inImage;
     int width;
     int height;
     private static JPEGImageWriteParam params;
     static {
          JPEGImageWriteParam params = new JPEGImageWriteParam(null);
          params.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
          params.setCompressionQuality(0.8f);
          params.setProgressiveMode(ImageWriteParam.MODE_DISABLED);
          params.setDestinationType(
               new ImageTypeSpecifier(IndexColorModel.getRGBdefault(),
               IndexColorModel.getRGBdefault().createCompatibleSampleModel(16,16)));
     public ImageResizer(byte[] image, long id) throws IOException
          inImage = ImageIO.read(new ByteArrayInputStream(image));
          width = inImage.getWidth(null);
          height = inImage.getHeight(null);
     public void makeSmallImage (File outputFile) throws IOException {
          resizeImage(120, outputFile);
     private void resizeImage (int maxDim, File file) throws IOException {
          double scale = maxDim / (double) height;
          if (width > height) scale = maxDim / (double) width;
          int scaledWidth = (int)(scale * width);
          int scaledHeight = (int)(scale * height);
          BufferedImage outImage = new BufferedImage(scaledWidth, scaledHeight, BufferedImage.TYPE_INT_RGB);
          AffineTransform xform = AffineTransform.getScaleInstance(scale, scale);
          AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
          // Paint image.
          Graphics2D g2d = outImage.createGraphics();
          g2d.drawImage(inImage, op, 0, 0);
          g2d.dispose();
          // write the image out
          ImageOutputStream ios = null;
          try {
               ios = ImageIO.createImageOutputStream(file);
               ImageWriter writer = (ImageWriter) ImageIO.getImageWritersByFormatName("jpg").next();
               writer.setOutput(ios);
               writer.write(null, new IIOImage(outImage, null, null), params);
               writer.dispose();
          catch (IOException e) {
               System.out.println("cought IOException while writing " +
               file.getPath());
          finally {
               if (null != ios) ios.close();
}

I am having the same problem with jpegs.
The strange thing is that this only happends with the same exact code on OS X, while it never happens on any windows machine.
I have tried using the the ImageIO classes, and a class I got off of this board a while back; however when using this class on an OS X machine, encoding takes a really long time and gives the pink distortion.
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.swing.*;
import com.sun.image.codec.jpeg.*;
import java.awt.event.*;
import java.util.*;
import java.awt.geom.*;
public class ImageUtils {
     private static JPEGImageEncoder encoder = null;
     private static FileOutputStream fileStream = null;
     public static BufferedImage createComponentImage(Component component)
          BufferedImage image = (BufferedImage)component.createImage(component.getWidth(),component.getHeight());
          Graphics graphics = image.getGraphics();
          if(graphics != null) { component.paintAll(graphics); }
          return image;
     public static void encodeImage(BufferedImage image, File file) throws IOException
          fileStream = new FileOutputStream(file);
          JPEGEncodeParam encodeParam = JPEGCodec.getDefaultJPEGEncodeParam(image);
          encoder = JPEGCodec.createJPEGEncoder(fileStream);
          encoder.encode(image,encodeParam);
}use it like this:
File file = new File("ImageTest.jpg");
image = ImageUtils.createComponentImage(imageCanvas);
ImageUtils.encodeImage(image,file);

Similar Messages

  • ImageSnapShot and Alchemy Jpeg encoder

    Hi!
    I was trying to figure out how can i use the Alchemy JPEG encoder with ImageSnapShot to capture image and encode with Alchemy encoder
    If you see the ImageSnapShot function to capture is:
         var jpg : JPEGEncoder = new JPEGEncoder();
         var imageSnap:ImageSnapshot = ImageSnapshot.captureImage(image, 0, jpg);
    I want to capture a BIG screen, using JPEGEncoder its impossible beacose times of encoding.
    So, some can anyone that had worked with this tell me if its possible?
    Thanks in advance
    And excuse about my english =)

    I have just put up a tutorial/guide on how to use the Alchemy JPEG encoder in Flash. It's also an example on how to use a progressbar to monitor the encoding. Check out http://last.instinct.se/graphics-and-effects/using-the-fast-asynchronous-alchemy-jpeg-enco der-in-flash/640

  • Problems with JPEG encoding

    I'm making photo album on the web. But I have a problem with thumbnails generation. I have read alot about it on this forum (thanks guys) but I have a problem:
    Sometimes (but not every time) and independent on the image I've got thumbnail picture that can not be readed neither by IE or Photoshop or another programm. I'm using next encoding sequence:
    PEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
    com.sun.image.codec.jpeg.JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bufferedImage);
    writeParam.setCompressionMode(JPEGImageWriteParam.MODE_EXPLICIT);
    param.setQuality(0.7f, true);
    encoder.setJPEGEncodeParam(param);
    encoder.encode(bufferedImage);
    And this code operate in the Servlet enviroment. So, I can not understand what is wrong?
    Renat.

    Hi Renat.
    I may be wrong but I have observed some troubles with JPEG encoding (particularly because of a lack of CPU)... You may have the same trouble... The problem is that I don't how to catch these errors but if someone knows how to, I would be really interested in... I can only catch them when I decode these images thanks to TruncatedFileException and ImageFormatException.
    Stephane.

  • Writing JPEG with ImageIO

    Hi,
    I wanted to do this little tool that:
    1. read any type of image format supported by ImageIO
    2. scaled it down to arbitrary size
    3. wrote the image to the same format it was originally
    I got the pieces together, used ImageIO to read the image, then java.awt.image.AffineTransformOp to scale it down and finally ImageIO again to write it back (I get the ImageWriter with ImageIO.getImageWriter(ImageReader)).
    The problem I got was that AffineTransformOp on Linux (it uses native code) does not want to output anything else then ARGB images. If I read a YCbCr JPEG (the most common JPEG format) and do the AffineTransformOp, I get this ARGB image, which ImageIO will happily write back as an JPEG, but as CMYK JPEG file (which is really rare and not understood by most browsers)... which is not fine because the original was YCbCr.
    The question now is, how do I get AffineTransformOp and ImageIO to play nicely together. Either I have to get AffineTransformOp to output to an BufferedImage that has the same colormodel as that read from the file, or I have to get ImageIO to write any BufferedImage to the exact same format as the original image file.
    For the special case I stated above, I got the program to work by converting the BufferedImage I got from AffineTransformOp to a BufferedImage with RGB colormodel. This, however is not the solution because it assumes that we do not want to output ARGB... Anyway I did it whith the following code (yes, it is horrible).
    // do scaling
    BufferedImage scaled = op.filter(original, null);
    // create a new RGB color model... no alpha
    ColorModel rgbcm = new DirectColorModel(24, 0x00ff0000, 0x0000ff00, 0x000000ff);
    // get the DataBuffer from the scaled version
    DataBuffer db = scaled.getRaster().getDataBuffer();
    // and its dimensions
    int w = scaled.getRaster().getWidth();
    int h = scaled.getRaster().getHeight();
    // band masks for rgb (no alpha)
    int[] bandMasks = new int[] {0x00ff0000,0x0000ff00, 0x000000ff}
    // create new WritableRaster that has the same data, but different sample model
    WritableRaster r = Raster.createPackedRaster(db, w, h, h, bandMasks, null);
    // create a new BufferedImage with the no-alpha ColorModel and the raster
    // with no-alpha SampleModel
    BufferedImage rgbimg = new BufferedImage(rgbcm,r, scaled.isAlphaPremultiplied(), null);
    My second question is, if I have to do this, is there any simpler way?

    I just did a project similar to this actually, so you're in luck! My project was doing image compression rather than resizing, but the IO is the same. I used PixelGrabber to get the pixels, then created my new image in a BufferedImage just like you did (so you can keep all your reading and image creation the same since you seemed to use a BufferedImage also).
    Once you have your BufferedImage, it's blazingly simple. There is a JPEGCodec package that is included in the JDK. It's not compiled though. but, if you open up the ZIP file that has the sources in it (it's copied to your java home directory, called "src.zip"), you can get all the sources you needed. In that package there are 2 classes that I used: JPEGCodec and JPEGImageEncoder. It works like follows:BufferedImage bi;
    OutputStream os;
    // create and fill your buffered image and instantiate your output stream (I used a FileOutputStream for obvious reasons).
    JPEGImageEncoder jie = JPEGCodec.createJPEGEncoder(os);
    jie.encode(bi); And that's it! The package does the rest! Let me know if you have any troubles with it.

  • Problem with ImageIO.read and ImageReader GIF becomes dark

    I am having problems with certain GIF images loading completely dark. I previously had problems with certain JPGs colors being distorted http://forum.java.sun.com/thread.jspa?threadID=713164&tstart=0. This was a problem in an old JDK.
    Here is the code:
                java.awt.image.BufferedImage bufferedImage = javax.imageio.ImageIO.read( new java.io.File("javabug.gif") );
                System.out.println( bufferedImage );
                javax.imageio.ImageIO.write( bufferedImage, "jpg", new java.io.File("badcolors.jpg") );
                javax.imageio.ImageIO.write( bufferedImage, "png", new java.io.File("badcolors.png") );BufferedImage Read is:
    BufferedImage@337838: type = 5 ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace@119cca4 transparency = 1 has alpha = false isAlphaPre = false ByteInterleavedRaster: width = 1536 height = 1152 #numDataElements 3 dataOff[0] = 2
    Here is the GIF
    http://www.alwaysvip.com/javabug.gif
    I am using jdk1.5.0_06
    If I use java.awt.Toolkit.getDefaultToolkit().getImage instead of ImageIO.read, the problem no longer exists.
            java.awt.Image image = java.awt.Toolkit.getDefaultToolkit().getImage( file.toURL() );
            java.awt.MediaTracker mediaTracker = new java.awt.MediaTracker( new java.awt.Container() );
            mediaTracker.addImage( image, 0 );
            mediaTracker.waitForID( 0 );
            java.awt.image.BufferedImage bufferedImage = new java.awt.image.BufferedImage( image.getWidth( null ), image.getHeight( null ), java.awt.image.BufferedImage.TYPE_INT_RGB );
            java.awt.Graphics g = bufferedImage.createGraphics();
            g.setColor( java.awt.Color.white );
            g.fillRect( 0, 0, image.getWidth( null ), image.getHeight( null ) );
            g.drawImage( image, 0, 0, null );
            g.dispose();
            javax.imageio.ImageIO.write( bufferedImage, "jpg", new java.io.File("goodcolors.jpg") );
            javax.imageio.ImageIO.write( bufferedImage, "png", new java.io.File("goodcolors.png") );BufferedImage Read is:
    BufferedImage@1bf216a: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 1536 height = 1152 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
    Is this another bug in the JDK? Is there a possible workaround where I can still use ImageIO.read?

    I figured out the problem. It was an actual BUG in the JDK!
    The code failed with the following JDKs:
    java version "1.5.0_01"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
    Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)
    java version "1.5.0_03"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
    Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode)
    The code ran sucessful with this JDK:
    java version "1.5.0_06"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
    Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
    If you are using the ImageIO classes, I highly suggest you upgrade to the latest JDK.
    Best,
    Scott

  • Problems with ImageIO.write()

    Well I am finding it very strange with ImageIO.write();
    Consider the following code snippet:
    BufferedImage img=ImageIO.read(new File("fw2.jpg"));
    BufferedImage img1=new BufferedImage(img.getWidth(),img.getHeight(),img.TYPE_INT_ARGB);
    for(int i=0;i<img.getHeight();i++)
    for(int j=0;j<img.getWidth();j++)
    img1.setRGB(j,i,img.getRGB(j,i));
    ImageIO.write(img1,"jpg",new File("fwinv.jpg"));
    So simply I am copying fw2.jpg to fwinv.jpg. fw2.jpg was also created
    using ImageIO.write().
    But the two files are having different pixel values.
    i.e If I read fwinv.jpg again I will get different pixel value that it was written.
    Why is this...Can any one please help me..

    Reading the written images back and displaying them in java works okay. The third image looks okay in RGB but wrong in ARGB when displayed by a native app. For more about this see reply 1 in Color problems and the linked bug report: Some Images written using JPEG Image Writer are not recognized by native applns.
    import java.awt.GridLayout;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    public class WriteTest {
        private JPanel getContent(BufferedImage src) throws IOException {
            File fileOne = new File("fileOne.jpg");
            ImageIO.write(src, "jpg", fileOne);
            BufferedImage image1 = ImageIO.read(fileOne);
            BufferedImage image2 = copy(image1);
            JPanel panel = new JPanel(new GridLayout(1,0));
            panel.add(new JLabel(new ImageIcon(src)));
            panel.add(new JLabel(new ImageIcon(image1)));
            panel.add(new JLabel(new ImageIcon(image2)));
            return panel;
        private BufferedImage copy(BufferedImage in) throws IOException {
            int w = in.getWidth();
            int h = in.getHeight();
            int type = BufferedImage.TYPE_INT_ARGB;   // problem in native apps
                       //BufferedImage.TYPE_INT_RGB;  // this one works okay
            BufferedImage out = new BufferedImage(w, h, type);
            for(int y = 0; y < h; y++) {
                for(int x = 0; x < w; x++) {
                    out.setRGB(x, y, in.getRGB(x, y));
            File fileTwo = new File("fileTwo.jpg");
            ImageIO.write(out, "jpg", fileTwo);
            return ImageIO.read(fileTwo);
        public static void main(String[] args) throws IOException {
            BufferedImage image = ImageIO.read(new File("images/cougar.jpg"));
            WriteTest test = new WriteTest();
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(test.getContent(image));
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }

  • Can you please help me fix a crackling/distortion problem that i have with AA when recording?

    I've read before on the forum that some other users have the same problem and I've tried quite about everything to fix my problem as well, but still no result.
    When I record, be it in AA 1 or in AA 3, i sometimes end up with channels being distorted (randomly!).
    Here's my config:
    I think it's important to say that I've been having this problem starting only a few months ago, though I haven't reinstalled Windows or anything. I'm working with windows XP SP3. I think (though i'm not sure) the problem occured about the same time I've updated my M-Audio drivers to version 5074. I've also tried disabling C1E as I've read on this forum on another topic and no result.
    Also,
    here's a sample of the crackling:
    http://dl.transfer.ro/transfer_ro-26jun-168e94ae4dc5d9.zip
    I'll send a bottle of Jack to whoever helps me fix this one Really now, I'm desperate!

    I don't hear crackling in that sample, myself, just a split-second rant in another language I can't identify, but anyhoo...
    1. Have you tried rolling back to the 5069 driver?
    http://www.m-audio.com/index.php?do=support.drivers&f=930
    2. Check out this thread:
    http://forums.m-audio.com/showthread.php?17641-**Official-Info-Delta-Series-Driver**-Updat ed-5-26&s=e3e523dd417e4335c48234bac735fa59
    I see you're having your issue in WinXP SP3.  One guy (see post 43 on page 5) reports it in Win 7 with this driver.  People have reported better success with the 5069 driver but that one has been reported to lock on shutdown in Win7.
    3. Check out this thread:
    http://forum.cakewalk.com/tm.aspx?high=&m=1998799&mpage=1#1998799
    Same driver, Win7, different M-Audio card, different sound program, but crackling/sizzling. Fix reported by OP in post 14 by adjusting BIOS settings:
    Disabling EIST (Enhanced Intel Speedstep Technology) and CPU C state in  the power section of the BIOS made all the crackle sizzle go away!
    There's a checkmark in the last window in your screenshots for that one.  Also discussion of suggestions to adjust latency, etc., in soundcard which didn't fix it for him but may have for others.
    If those give no joy, please post motherboard brand and model.
    Message was edited by: Mel Davis.  Addition to suggestion #3.

  • Problems when jpeg encoding multiple images

    Hi, im trying to write a servlet which generates multiple thumbs. However when encoding for the second time i get an error java.io.IOException: reading encoded JPEG Stream.
    I can't figure out the problem
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.awt.Image;
    import java.awt.Graphics2D;
    import java.awt.geom.AffineTransform;
    import java.awt.image.BufferedImage;
    import javax.swing.ImageIcon;
    import com.sun.image.codec.jpeg.JPEGCodec;
    import com.sun.image.codec.jpeg.JPEGImageEncoder;
    public class Thumbs extends HttpServlet {
      private String dbDriver = "com.mysql.jdbc.Driver";
      private String dbURL = "jdbc:mysql://localhost/shopper?";
      private String userID = "javauser";
      private String passwd = "javadude";
      private Connection dbConnection;
      //Initialize global variables
      public void init() throws ServletException {
      //Process the HTTP Get request
      public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        try{
          String foreignNr = request.getParameterValues("p")[0];
          String maxDim = request.getParameterValues("s")[0];
          if (foreignNr != null){
            int foreignID = Integer.parseInt(foreignNr);
            int maxDimension = Integer.parseInt(maxDim);
            response.setContentType("image/jpeg");
            OutputStream out = response.getOutputStream();
            writeThumbnailPictures(out,foreignID,maxDimension);
        } catch (Exception ex){
            log(ex.getMessage());
      public void writeThumbnailPictures(OutputStream out,int foreignID,int maxDimension){
        try{
          Class.forName(dbDriver);
          dbConnection = DriverManager.getConnection(dbURL, userID, passwd);
          PreparedStatement pageStatement;
          pageStatement = dbConnection.prepareStatement(
              "select * from pictures where ForeignID = ?");
          pageStatement.setInt(1, foreignID);
          ResultSet recs = pageStatement.executeQuery();
          while (recs.next()) {
            byte[] data = recs.getBytes("Picture");
            if (data != null) {
              Image inImage = new ImageIcon(data).getImage();
              // Determine the scale.
               double scale = (double)maxDimension / (double)inImage.getHeight(null);
               if (inImage.getWidth(null) > inImage.getHeight(null)) {
                   scale = (double)maxDimension /(double)inImage.getWidth(null);
               // Determine size of new image.
               // One of them should equal maxDim.
               int scaledW = (int)(scale*inImage.getWidth(null));
               int scaledH = (int)(scale*inImage.getHeight(null));
               // Create an image buffer in
               //which to paint on.
               BufferedImage outImage = new BufferedImage(scaledW, scaledH,
                   BufferedImage.TYPE_INT_RGB);
               // Set the scale.
               AffineTransform tx = new AffineTransform();
               // If the image is smaller than
               // the desired image size,
               // don't bother scaling.
               if (scale < 1.0d) {
                   tx.scale(scale, scale);
               // Paint image.
               Graphics2D g2d = outImage.createGraphics();
               g2d.drawImage(inImage, tx, null);
               g2d.dispose();
               // JPEG-encode the image
               JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
               encoder.encode(outImage);
          out.close();
        catch(Exception ex){
          ex.printStackTrace();
      //Clean up resources
      public void destroy() {
    }

    Hi,
    I am facing same problem while generating the thumbs. Did you figure out what the problem is? if you have the solution, do post it.
    Thanks in advance
    Mo

  • Jpeg Encoding Problem

    Hello,
    I have an applet that reads a data file and plots a graph. Now i'm having problem converting the graph into a jpg file using a jpeg encoder.
    I have the following snippet of code in the end.
    File file = new File("c:\\vj\\graph.jpg");
         if (file.exists()) {file.delete();}
         try {file.createNewFile();} catch (IOException eIo) {}
         try
         OutputStream out = new FileOutputStream( file );
         Image image = (Image)chart2D.createImage(chart2D.getWidth() ,chart2D.getHeight());
         Graphics g = image.getGraphics();
         chart2D.paint(g);
         BufferedImage bufImage = (BufferedImage)image;
    //     JPEGEncodeParam jep = new JPEGEncodeParam();
         JPEGImageEncoder jencoder = JPEGCodec.createJPEGEncoder(out);
         jencoder.encode(bufImage);
         out.flush();
         out.close();
         } catch (IOException e) {}
    But when i run the applet it gives me a security exception saying:
    java.security.AccessControlException: access denied (java.io.FilePermission c:\vj\graph.jpg read)
    How do i fix this problem??
    Any help would be appreciated,
    Thanks,
    Mamtha.

    Unfortunately, you can't do file I/O from an applet unless it is a signed applet. See applet security FAQ:
    http://java.sun.com/sfaq/
    If it's at all feasible, by far the simplest solution is to add a min method and make it an application instead of an applet. If it must be an applet, things get a little more complicated! Here are a couple of possibilities:
    1) You could sign your applet. For an example, see:
    http://java.sun.com/security/signExample/
    2) You can send the file to the server where the applet came from, and then have the server write it to disk. Finally, the client can request the file from the server. For an explanation and example code, see:
    http://java.sun.com/docs/books/tutorial/applet/practical/workaround.html

  • JPEG ENCODING AND DECODİNG WITH DCT TRANSFORMATION

    I NEED A JAVA SOURCE CODE JPEG ENCODING AND DECOD&#304;NG WITH DCT TRANSFORMATION ALSO QUANTIZATION. IT IS URGENT BECAUSE I WILL USE IT IN MY PROJECT AND I AM NOT GOOD AT JAVA . PLEASE I AM WAITING YOUR HELPS. MY MAIL IS [email protected] thank you very much

    I NEED A JAVA SOURCE CODE JPEG ENCODING AND DECOD�NG WITH DCT TRANSFORMATION ALSO QUANTIZATION. IT IS URGENT BECAUSE I WILL USE IT IN MY PROJECT AND I AM NOT GOOD AT JAVA . PLEASE I AM WAITING YOUR HELPS. MY MAIL IS [email protected] thank you very much

  • I still have a warranty but it will be out in a week. i previously have a sound distortion problem with my mac for months and suddenly it just fix itself. what should i do? i'm worried that it will comeback and i dont have a warranty anymore.

    i still have a warranty but it will be out in a week. i previously have a sound distortion problem with my mac for months and suddenly it just fix itself. what should i do? i'm worried that it will comeback and i dont have a warranty anymore.

    JoBautista,
    you still have the option (before your warranty expires) of purchasing an AppleCare Protection Plan, which will provide an additional two years of coverage. Once your warranty expires, you will no longer have the option of purchasing AppleCare.

  • Distortion problems with new iPod Classic

    Hello:
    I recently purchased a 160GB iPod Classic to replace a 2-year-old 60GB iPod. I had no problems updating the new one; about a zillion tracks went in very smoothly in about a half-hour. But I have noticed a couple of problems:
    First, I always listen to my iPod at work on a Klipsch dock, and even though I keep it set at a fairly low volume (all of the content is classical music), I'm getting crackling and distortion in random spots in music. It doesn't seem to matter if the music was downloaded from iTunes or imported from a CD. It's definitely not the dock, because I tried the old iPod on it and it worked as well as it always did.
    Second, when I select a playlist and start playback, I notice that more often than not, the first second or two of music is cut off. I have to press the back arrow on the iPod, and then playback is correct.
    That is a minor annoyance, but the the distortion problem is far more serious. I never had either problem on the old iPod, and I was wondering if anyone has experienced similar problems with the iPod Classic. I'd HATE to think I'd have to trash 40GB of music and start all over importing CDs.
    Thanks for any input you can give me.

    thanks for the suggestion but it did not work.
    The iPod came up asking for the password (WEP key) and i entered it. It showed connected with the router but Safari does not work and when i check the DHCP entries in see the following
    IP: 169.254.202.45
    Sub: 255.255.0.0
    This means that the connection was made but the router DHCP server did not assign an IP address to the iPod.
    This exact problem i have encoutered so far in my office, a cofeeshop and a car dealership. In all cases the wirelles was based on an older linksys router and except in the case of my office the other two were unsecured networks.
    I believe it has something to do with the firmware on those linksys routers causing a problem specificaly to iPods and i would guess iPhones too since they have the same OS.
    I'm open to any suggestions but i've tried all the ones posted in this and other forums so far with no luck.
    When i assign a static IP, the iPod again connects, the router log indicates outgoing traffic from that IP but there is no incomming traffic.
    John

  • Rendering A JPEG image with a custom tag

    Hi All,
    I have dilema. I'm trying to rendering a jpeg in IE/FireFox with a custom tag that I developed. I'm able to access the bean and invoke the getter method to return the InputStream property. But what gets rendered is the byte code not the image. I've tried just about anything I could think off. If any body has an answer I would difinitely appreciate it.
    Thanks,
    Tony
    Below is the jsp, tld, bean and tag.
    ********************************* image.jsp ****************************************
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@ taglib uri="/WEB-INF/custom-chtml.tld" prefix="chtml" %>
    <html>
    <head>
    <title>HTML Page</title>
    </head>
    <body bgcolor="#FFFFFF">
    <chtml:img name="photo" property="file"/>
    </body>
    </html>
    ********************************* custom-chtml.tld **********************************
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
    <taglib>
    <tlibversion>1.0</tlibversion>
    <jspversion>1.1</jspversion>
    <shortname>chtml</shortname>
    <tag>
    <name>img</name>
    <tagclass>com.struts.taglib.CustomImgTag</tagclass>
    <bodycontent>empty</bodycontent>
    <attribute>
    <name>name</name>
    <required>false</required>
    <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
    <name>property</name>
    <required>true</required>
    <rtexprvalue>true</rtexprvalue>
    </attribute>
    </tag>
    </taglib>
    **************************** MemberPhotoBean.java ******************************
    import java.io.InputStream;
    * @author tony
    * TODO To change the template for this generated type comment go to
    * Window - Preferences - Java - Code Style - Code Templates
    public class MemberPhotoValue {
         private String memberId;
         private int fileSize;
         private InputStream file;
         public MemberPhotoValue() {
         public MemberPhotoValue(String memberId, InputStream file) {
              this.memberId = memberId;
              this.file = file;
         public MemberPhotoValue(String memberId,int fileSize,InputStream file) {
              this.memberId = memberId;
              this.fileSize = fileSize;
              this.file = file;          
         public String getMemberId(){
              return memberId;
         public void setMemberId(String memberId) {
              this.memberId = memberId;
         public int getFileSize() {
              return fileSize;
         public void setFileSize(int fileSize) {
              this.fileSize = fileSize;
         public InputStream getFile(){
              return file;
         public void setFile(InputStream file) {
              this.file = file;
    *************************** CustomTagHandler.java ********************************
    import java.io.*;
    import javax.imageio.ImageIO;
    import javax.servlet.*;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    import java.lang.reflect.Method;
    import java.lang.reflect.InvocationTargetException;
    import java.awt.image.*;
    import java.awt.*;
    import javax.swing.ImageIcon;
    import com.sun.image.codec.jpeg.*;
    * JSP Tag Handler class
    * @jsp.tag name = "CustomImg"
    * display-name = "Name for CustomImg"
    * description = "Description for CustomImg"
    * body-content = "empty"
    public class CustomImgTag implements Tag {
         private PageContext pageContext;
         private Tag parent;
         private String property;
         private String name;
         private Class bean;
         public int doStartTag() throws JspException {
              return SKIP_BODY;
         public int doEndTag() throws JspException {
         try {
         ServletResponse response = pageContext.getResponse();
         // read in the image from the bean
         InputStream stream = (InputStream) invokeBeanMethod();
         BufferedImage image = ImageIO.read(stream);          Image inImage = new ImageIcon(image).getImage();
         Graphics2D g = image.createGraphics();
         g.drawImage(inImage,null,null);               
         OutputStream out = response.getOutputStream();
    // JPEG-encode the image
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
    encoder.encode(image);               
         out.close();     
    } catch (IOException io) {
              throw new JspException(io.getMessage());
         return EVAL_PAGE;
         public void release(){}
    private InputStream invokeBeanMethod() throws JspException {
         try {
         Object bean = null;
         if (null != pageContext.getAttribute(name)) {
         bean = (Object) pageContext.getAttributename);
         else if (null != pageContext.getSession().getAttribute(name)) {
         bean = (Object) pageContext.getSession().getAttribute(name);
         else if (null != pageContext.getRequest().getAttribute(name)) {
         bean = (Object) pageContext.getRequest().getAttribute(name);
         else {
         throw new JspException("Bean : "+name+" is not found in any pe.");
         Class[] parameters = null;
         Object[] obj = null;               
         Method method = bean.getClass().getMethod("getFile",parameters);
         return (InputStream) method.invoke(bean,obj);
         } catch (NoSuchMethodException ne) {
         throw new JspException("No getter method "+property+" for bean : "+bean);
         } catch (IllegalAccessException ie) {
         throw new JspException(ie.getMessage());
         } catch (InvocationTargetException ie) {
         throw new JspException(ie.toString());
         public void setPageContext(PageContext pageContext) {
              this.pageContext = pageContext;
         public void setParent(Tag parent) {
              this.parent = parent;
         public Tag getParent() {
              return parent;
         public void setProperty(String property) {
              this.property = property;
         public void setName(String name) {
              this.name = name;
    **************************************************************************************

    If you have access to an image editing tool such as photoshop, I would advice you import the image into Phototshop and save it in a different format e.g, GIF format and re-import it into Final Cut Express HD. This could solve your rendering problem if all you need is to use a Still image.
    Ayemenre

  • Adding JPEG attachmentPart with SAAJ

    Hi
    I am trying to send a SOAP with attachments messaage
    with the followong code.
    File jf = new File("Footie.JPG");
    FileInputStream jfis = new FileInputStream(jf);
    ap.setMimeHeader("Content-Type", "image/jpeg");
    ap.setContent(jfis, "image/jpeg");
    soapMessage.addAttachmentPart(ap);
    System.out.println("Ready to send message");
    SOAPMessage response = sc.call(soapMessage, url);
    i.e just reading a JPG file and with a fileinputstream.
    I get an exception saying that something about security exception and
    unable to run JPEG encoder on stream null.
    [java] Caused by: java.io.IOException: Unable to run the JPEG Encoder
    on a
    stream null
    [java] javax.xml.soap.SOAPException:
    java.security.PrivilegedActionExceptio
    n: javax.xml.soap.SOAPException: Error during saving a multipart message
    [java] at
    com.sun.xml.messaging.saaj.soap.JpegDataContentHandler.writeT
    o(JpegDataContentHandler.java:144)
    Has anyone come across anything like this ?
    Henry

    Did anyone answer this one? I'm still stuck on this exact same problem..
    I'm guessing it has something to do with set up but I'm not getting anywhere...
    Thanks

  • File encoded with x264 takes forever to load in Encore CS 5.5

    I use Encore mostly because it takes h.264 video encoded with the x264 compressor, which provides much higher quality than any other compressor. The problem is that these files take forever to load. For example, right now I'm trying to load a video that is about 1 hour and 20 minutes long, encoded at 38 Mbps, and the file is 20.9 GBytes. Now it's 3 PM and I imported this file along with the AC3 file over an hour ago. The Encore process shows as not responding, but when I open the Windows 7 Resource Monitor, in the disk tab it shows that it's reading the video file at a rate of about 45 MB/s, so I didn't kill the Encore process. I know eventually it's going to stop and load the file, but I don't understand why it takes so long. The encoding parameters that I used in x264 are these:
    x264 --level 4.1 --bluray-compat --preset slow --bitrate 38000 --keyint 30 --min-keyint 2 --open-gop --weightp 0 --slices 4 --vbv-bufsize 30000 --vbv-maxrate 40000 --rc-lookahead 40 --tff --output "output" "input"
    This comes from a family video that is 1080 59.94i. This time these two parameters appeared because I selected Blu-ray as the target:  --bluray-compat and --open-gop, which I don't normally use, but still, even when I don't use them, video encoded with x264 takes forever to load. Does anybody here know what could be the problem?

    What's weird is last year I encoded a file that was almost two hours long and Encore took it without trouble, although it was CS5, not 5.5. Since I had kept the avs and bat files, and also the x264.exe from that encode, I brought them into the current working folder and I just modified the file names in the avs and bat files to point to the new avi and encode to the new h264 file. So I encoded this file, I imported it into Encore, and it still hangs. Maybe it was a change from CS5 to 5.1 that introduced a problem. x264 has been certified to be Blu-ray compliant since over a year ago, and I already put this file to a Blu-ray with TSMuxer, since it was a family video and I didn't really need menus, and it plays perfectly fine in my Blu-ray player.
    But I'm sure there must be something, one or two parameters that would make it compatible. For example, after encoding the file again the last time, now I can import it into Encore, and it doesn't stay frozen forever, but it doesn't show me the video and as soon as I try to move the timeline cursor it freezes and doesn't let me do anything for several minutes. So still it's not usable. But it's a change from the first encode where the progress dialog would be there for several hours and do nothing at all.

Maybe you are looking for