Skip to content

Instantly share code, notes, and snippets.

@Visgean
Created April 18, 2017 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Visgean/0aa73e5e97f2b21f746b958e7e579ba2 to your computer and use it in GitHub Desktop.
Save Visgean/0aa73e5e97f2b21f746b958e7e579ba2 to your computer and use it in GitHub Desktop.
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class Main {
public static void main(String[] args) {
if (args.length == 0) {
System.out.println("Yo man. Give me filename.");
System.exit(1);
}
try
{
// the line that reads the image file
BufferedImage image = ImageIO.read(new File(args[0]));
// work with the image here ...
}
catch (IOException e)
{
System.out.println("Image not found.");
System.exit(1);
}
System.out.printf("Image resolution %dx%d", image.getWidth(), image.getWidth());
}
}
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class Main {
public static void main(String[] args) {
if (args.length == 0) {
System.out.println("Yo man. Give me filename.");
System.exit(1);
}
try
{
// the line that reads the image file
BufferedImage image = ImageIO.read(new File(args[0]));
// work with the image here ...
System.out.printf("Image resolution %dx%d", image.getWidth(), image.getWidth());
}
catch (IOException e)
{
System.out.println("Image not found.");
System.exit(1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment