Solved

Find dimensions of directory/GIF/JPEG

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

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
map related example 6 59
add projects t working set in maven 2 37
jmeter usage 4 33
Github api to fetch the number of collaborators in a git repo 1 25
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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

735 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