Tratamento de imagens

Gente…
preciso descobrir a dimensao de uma imagem e depois pegar os valores dos pixels desta imagem…
FIz um codigo bem tosco aqui pra testar, mas nao quer dar certo…
algem tem alguma ideia?

BufferedImage image = ImageIO.read(new File(args[0]));    
        ImageIO.write(image,"JPG",new File("hugo.JPG"));
        int width = image.getWidth();
        int height = image.getHeight();
        int nbands = image.getSampleModel().getNumBands();
        Raster inputRaster = image.getData();
        int[] pixels = new int[nbands*width*height];
        inputRaster.getPixels(0,0,width,height,pixels);
        for(int h=0;h<height;h++)
            for(int w=0;w<width;w++) {
            int rgb = image.getRGB(w,h);
            int r = (int)((rgb&0x00FF0000)>>>16); // Red level
            int g = (int)((rgb&0x0000FF00)>>>8); // Green level
            int b = (int) (rgb&0x000000FF); // Blue level
            System.out.print("at ("+w+","+h+"): ");
            System.out.println(r+","+g+","+b);
            
            }

[size=“11”][color=“red”]* Editado: Lembre-se de utilizar BBCode em seus códigos - Ratinho[/color][/size] :joia:

tp… manda o erro ai pra gente dar uma olhada :joia: