convert 24 bit jpeg to 256 color gif

Posted on 2006-03-20
Last Modified: 2013-11-19

I have a 24 bit jpeg image which I am reading into an buffered image.
I am using BufferedImage.TYPE_INT_RGB.

Now, I have a class called GIFEncoder (downloaded, author: Adam Doppelt) which takes a BufferedImage and encodes it into gif image. But, it does not accepts 24 bit buffered image.

Should I go for another GIF Encoder which does 24 bit to 8 bit quantization also?
If yes, please tell a GIFEncoder which is freely available, can take BufferedImage as input and encodes a gif out of it.

Question by:vaibhavmishra062201
    LVL 92

    Accepted Solution

    LVL 30

    Expert Comment

    I think you need to search for Graphics Gems II III.2 by Xialoin Wu.
    LVL 35

    Expert Comment

    Assuming your 24 bit image is in an image called "frame", you can do:

          BufferedImage indexedImage = new BufferedImage( frame.getWidth(), frame.getHeight(), BufferedImage.TYPE_BYTE_INDEXED ) ;
          Graphics g = indexedImage.getGraphics() ;
          g.drawImage( frame, 0, 0, null ) ;
          g.dispose() ;

    Then, "indexedImage" contains your 256 color image which should be addable to the GifEncoder

    Author Comment

    Thanks objects, but you forgot to mention other 2 classes used in AnimatedGifEncoder (LZWEncoder & NeuQuant)
    TimYates: I tried AnimatedGifEncoder suggested by objects and it worked fine. Thanks anyway.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Suggested Solutions

    Title # Comments Views Activity
    commonTwo  challenge 63 68
    triangle challenge 4 35
    return in catch statement 1 32
    json format text only 4 46
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
    Learn how to create interesting presentations by including videos to keep your audience engaged using Prezi. Select "Insert" from the top menu in your Prezi editor: Select "YouTube Video": Paste the video URL into the prompt: "Select "Insert":…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now