Results 1 to 9 of 9
  1. #1
    ronaldo121 is offline Member
    Join Date
    Mar 2010
    Posts
    10
    Rep Power
    0

    Default Java Gif image analyser

    Need help with a gif image analyser basically the gif image is a binary file so will use the BinInput file but from the gif file i need to get height, width etc

    Could someone please help?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by ronaldo121 View Post
    Need help with a gif image analyser basically the gif image is a binary file so will use the BinInput file but from the gif file i need to get height, width etc
    I don't know what BinInput is but myself I'd use ImageIO's static read(File gifFile) method to read in the GIF into a BufferedImage object and use the BufferedImage methods to determine the GIF's height, width, etc...

  3. #3
    ronaldo121 is offline Member
    Join Date
    Mar 2010
    Posts
    10
    Rep Power
    0

    Default

    please could you provide an example as i am puzzled if you don't mind please

  4. #4
    m00nchile is offline Senior Member
    Join Date
    Feb 2010
    Location
    Ljubljana, Slovenia
    Posts
    470
    Rep Power
    5

    Default

    Well, Fubarable gave you the steps necessary to do what you want, now it's up to you to do a bit of research. Java API's are free after all, and learning how to find something is just as important as learning to program efficiently. Just google "java ImageIO", "java BufferedImage", and things will get clearer.
    Ever seen a dog chase its tail? Now that's an infinite loop.

  5. #5
    ronaldo121 is offline Member
    Join Date
    Mar 2010
    Posts
    10
    Rep Power
    0

    Default

    right thansk mate

  6. #6
    ronaldo121 is offline Member
    Join Date
    Mar 2010
    Posts
    10
    Rep Power
    0

    Default

    so far i have this but it is wrong please can someone help me

    public class bufferedImage{
    public static void main(String[] args) {

    int w = bufferedImage.getWidth(null);
    int h = bufferedImage.getHeight(null);

    }
    }

  7. #7
    ronaldo121 is offline Member
    Join Date
    Mar 2010
    Posts
    10
    Rep Power
    0

    Default

    import java.io.*;

    public class ShowGIFData {

    public static void main(String[] args) throws IOException {

    byte[] b = new byte[10];

    FileInputStream is = new FileInputStream(args[0]);

    is.read(b);

    int height = 256*heightMSB + heightLSB;

    int widthLSB = b[6] & 0xFF;
    int heightLSB = b[8] & 0xFF;
    int heightMSB = b[9] & 0xFF;
    int widthMSB = b[7] & 0xFF;
    int width = 256*widthMSB + widthLSB;

    System.out.println("File: "+args[0]);
    System.out.println("Height: "+height);
    System.out.println("Width: "+width)
    System.out.println("Signature: "+(char)b[0]+(char)b[1]+(char)b[2]);
    System.out.println("Version: "+(char)b[3]+(char)b[4]+(char)b[5]);

    }}

  8. #8
    ronaldo121 is offline Member
    Join Date
    Mar 2010
    Posts
    10
    Rep Power
    0

    Default

    I need some help with this code please

  9. #9
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    (As already pointed out the ImageIO and associated classes like ImageReader are probably the way to go. Do you have some reason for wanting to roll your own gif parser?)

    At this point your problem seems to be with basic Java syntax. If your code won't compile and you can't understand its message then it will be helpful to post the exact and entire compiler message.

Similar Threads

  1. Replies: 2
    Last Post: 03-27-2010, 09:01 AM
  2. Protocol Analyser using jpcap
    By shahdharmit in forum Networking
    Replies: 0
    Last Post: 10-16-2009, 12:54 PM
  3. Replies: 14
    Last Post: 04-10-2009, 08:46 AM
  4. Replies: 0
    Last Post: 01-08-2008, 05:29 PM
  5. JavaLog Analyser 20070507
    By levent in forum Java Software
    Replies: 0
    Last Post: 05-10-2007, 05:47 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
  •