/**
* @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);
}
}
- metadata-extractor-2.3.1.jar (86.7 KB)
- 下载次数: 0
- mediautil-1.0.jar (117 KB)
- 下载次数: 0