Solved

Find dimensions of directory/GIF/JPEG

Posted on 2011-02-11
4
644 Views
Last Modified: 2013-11-23
Dear Experts,
I would like to produce below result for my own small program
Which will find out length , size and compression of directory JPEEG and GIF images.
Any one can help me with JAVA core programming here..

C:\Java Programt>java PicInfo pic1.jpg
name: pic1.jpg, type: JPEG-image
  length:      68676
  size:        1050 x 681
  compression: 4%

Thank you in advance:-)

0
Comment
Question by:rachel88
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 40

Assisted Solution

by:gurvinder372
gurvinder372 earned 250 total points
ID: 34871167
0
 
LVL 4

Accepted Solution

by:
aaver earned 250 total points
ID: 34936913
I think this should be helpful to start with:
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class ImageInfo {
    public static void main( String[] args ) throws IOException {
	for (String fileName : args) {
	    File file = new File( fileName );
	    BufferedImage image = ImageIO.read( file );
	    System.out.println( "name: " + fileName );
	    System.out.println( "type: " + (fileName.toLowerCase( ).endsWith( "jpg" ) ? "JPEG-image" : "GIF-image") );
	    System.out.println( "size: " + image.getWidth( ) + " x " + image.getHeight( ) );
	    System.out.println( "length: " + file.length( ) );
	    System.out.println( "compression: " + (100 * file.length( ) / (image.getRaster( ).getNumBands( ) * image.getWidth( ) * image.getHeight( ))) + "%" );
	}
    }
}

Open in new window

0
 
LVL 60

Expert Comment

by:Kevin Cross
ID: 36923063
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Suggested Courses

737 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