diff options
Diffstat (limited to 'juick-server-web/src/main/java/com/juick/server/util')
-rw-r--r-- | juick-server-web/src/main/java/com/juick/server/util/ImageUtils.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/juick-server-web/src/main/java/com/juick/server/util/ImageUtils.java b/juick-server-web/src/main/java/com/juick/server/util/ImageUtils.java index 25345439..7f21c0a5 100644 --- a/juick-server-web/src/main/java/com/juick/server/util/ImageUtils.java +++ b/juick-server-web/src/main/java/com/juick/server/util/ImageUtils.java @@ -18,6 +18,7 @@ package com.juick.server.util; +import org.apache.commons.imaging.ImageInfo; import org.apache.commons.io.FilenameUtils; import org.apache.commons.imaging.ImageReadException; import org.apache.commons.imaging.Imaging; @@ -149,4 +150,13 @@ public class ImageUtils { ImageIO.write(Scalr.resize(originalImage, 96), targetExt, Paths.get(imgDir, "a", targetName).toFile()); ImageIO.write(Scalr.resize(originalImage, 32), targetExt, Paths.get(imgDir, "as", targetName).toFile()); } + + public static Integer getImageHeight(File imageFile) throws IOException, ImageReadException { + ImageInfo info = Imaging.getImageInfo(imageFile); + return info.getHeight(); + } + public static Integer getImageWidth(File imageFile) throws IOException, ImageReadException { + ImageInfo info = Imaging.getImageInfo(imageFile); + return info.getWidth(); + } }
\ No newline at end of file |