/** * @Description: 判断图片是否被PS过 * @Param: [picPath] * @return: java.lang.String * @Author: chuanyin.li * @Date: 2018/11/8 */ public static String isPsFlag(String picPath){ String isPsFlag = "0"; try { File jpegFile = new File(picPath); Metadata metadata = JpegMetadataReader.readMetadata(jpegFile); Directory exif = metadata.getDirectory(ExifDirectory.class);//这里要稍微注意下 Iterator tags = exif.getTagIterator(); while (tags.hasNext()) { Tag tag = (Tag)tags.next(); System.out.println(tag+"==="+tag.getDirectoryName()+"====="+tag.getTagName()+"====="+tag.getDescription()); if(tag.getDescription().contains("Adobe Photoshop")) isPsFlag = "1"; } } catch (Exception e) { e.printStackTrace(); } return isPsFlag; } /** * @Description: 获取文件 exif信息 * @Param: [exif] * @return: java.lang.String * @Author: chuanyin.li * @Date: 2018/11/8 */ public static String getOrientationDescription(Directory exif) throws MetadataException { if (!exif.containsTag(ExifDirectory.TAG_ORIENTATION)) return null; int orientation = exif.getInt(ExifDirectory.TAG_ORIENTATION); switch (orientation) { case 1: return "Top, left side (Horizontal / normal)"; case 2: return "Top, right side (Mirror horizontal)"; case 3: return "Bottom, right side (Rotate 180)"; case 4: return "Bottom, left side (Mirror vertical)"; case 5: return "Left side, top (Mirror horizontal and rotate 270 CW)"; case 6: return "Right side, top (Rotate 90 CW)"; case 7: return "Right side, bottom (Mirror horizontal and rotate 90 CW)"; case 8: return "Left side, bottom (Rotate 270 CW)"; default: return String.valueOf(orientation); } }
Java获取获取exif信息
/**
* @Description: 判断图片是否被PS过
* @Param: [picPath]
* @return: java.lang.String
* @Author: chuanyin.li
* @Date: 2018/11/8
*/
public static String isPsFlag(Str...
- 发表于 2018-11-09 13:59
- 阅读 ( 515 )
- 分类:网络文章
你可能感兴趣的文章
- Java 添加条码、二维码到PDF文档 134 浏览
- Java 在Excel中添加筛选器并执行筛选 91 浏览
- JAVA + VUE + 简洁UI:分离式软件平台形成之旅 265 浏览
- Java 设置Word中的表格自适应的3种方式 113 浏览
- LeaRun快速开发平台,.net/java项目开发工具简析 142 浏览
- JVM学习笔记之类装载器-ClassLoader 203 浏览
随机文章
- Java字符串(String)转成char[]数组,char数组转String 3956 浏览
- Java字符串(String)转成byte[]数组,byte数组转String 3400 浏览
- 结合源码浅析Struts2与Spring整合的原理 3296 浏览
- java对竖线|进行分割(split)操作 3668 浏览
- MySQL中查询、删除重复记录的方法大全 4212 浏览
相关问题
- java基础知识提问 1 回答
条评论
请先 登录 后评论
发送私信
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!