P2 2021/22 - DN12 velikost png slike - resitev Starc Aljaz¶
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import javax.imageio.ImageIO;
public class DN12 {
public static void main (String[] args) {
try {
File file = new File(args[0]);
if (!file.exists() || file.isDirectory()) throw new Exception("File does not exist");
if (!Files.probeContentType(Path.of(file.getAbsolutePath())).equals("image/png")) throw new Exception("File is not image/png");
System.out.format(
"%d x %d\n",
ImageIO.read(file).getWidth(),
ImageIO.read(file).getHeight()
);
} catch (Exception e) { System.out.println("?"); }
}
}
Zadnja posodobitev:
May 24, 2022