The following code snippet shows how to calculate image dimension in java by reading the file from specified path.
public static Dimension getImageDimension(final File path) {
if (path == null) return null;
Dimension result = null;
String suffix = getFileExtension(path.toString());
if (suffix.startsWith("."))
suffix = suffix.substring(1);
final Iterator<ImageReader> iterator = ImageIO.getImageReadersBySuffix(suffix);
if (iterator.hasNext()) {
final ImageReader reader = iterator.next();
try {
...
Posted under . Read full article from Stacktips.
Follow author on twitter https://twitter.com/npanigrahy.
No comments:
Post a Comment