Results 1 to 4 of 4
  1. #1
    Maz
    Maz is offline Member
    Join Date
    Jul 2008
    Posts
    1
    Rep Power
    0

    Default Extracting jpg from animated gifs

    Hi There

    I have a problem

    I have an animted gif, where i want to extract a jpg from
    so i access the gif , and handle each frame as a BufferedImage
    so far so good, that works

    but if i try to create a jpg from a certain buffered Image
    i get a jpg that has completly corrupted colors
    It looks very reddish, like there would have been a filter applies to it!

    Can anyone help me and tell me where the problem is?:confused:

    best wishes
    maz

  2. #2
    David M. is offline Member
    Join Date
    Apr 2011
    Location
    Kansas
    Posts
    26
    Rep Power
    0

    Default

    If you wanted to you could just use the animated gif itself in your program. You don't need to convert it to another file type.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,452
    Rep Power
    20

    Default

    Zombie alert

    db

  4. #4
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    Location
    London, UK
    Posts
    797
    Blog Entries
    2
    Rep Power
    4

    Default

    Quote Originally Posted by Maz View Post
    but if i try to create a jpg from a certain buffered Image
    i get a jpg that has completly corrupted colors
    It looks very reddish, like there would have been a filter applies to it!
    You can't load all of an animated gif into a buffered image as BufferedImage only supports static images.

    If you actually want to get at the pixel data of the images, then you will need to get the image reader for gif e.g.
    Java Code:
    ImageIO.getImageReadersBySuffix("gif").next()

    Then use setInput on it with an ImageInputStream e.g.
    Java Code:
    imageReader.setInput(ImageIO.createImageInputStream(file))

    Then use readAll to get an iterator of all the frames:
    Java Code:
    for (IIOImage image : imageReader.readAll(null)) {
        ...
    }
    And finally use getRenderedImage on the IIOImage to get the BufferedImage for that frame.

Similar Threads

  1. Animation with Animated GIF
    By JavaBean in forum Java 2D
    Replies: 3
    Last Post: 06-04-2011, 05:26 PM
  2. Extracting JAR file
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-08-2008, 10:17 AM
  3. Extracting embedded files
    By kasturi in forum New To Java
    Replies: 0
    Last Post: 02-07-2008, 01:25 PM
  4. program help: Extracting words from a string
    By toad in forum New To Java
    Replies: 1
    Last Post: 11-04-2007, 07:39 PM
  5. Extracting data from an XML file...
    By techno_brains in forum New To Java
    Replies: 1
    Last Post: 07-15-2007, 06:46 PM

Posting Permissions

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