Solved

Find dimensions of directory/GIF/JPEG

Posted on 2011-02-11
4
647 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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

696 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