Get all metadata
Added method to extract all metadata from image.
Merge request reports
Activity
191 ", fileType='" + fileType + '\'' + 192 ", photoDate='" + photoDate + '\'' + 193 ", fileSize='" + fileSize + '\'' + 194 ", fileDimension='" + fileDimension + '\'' + 195 '}'; 199 "\nmetadataId=" + metadataId + 200 "\ncamera='" + camera + '\'' + 201 "\nlens='" + lens + '\'' + 202 "\naperture='" + aperture + '\'' + 203 "\nshutterSpeed='" + shutterSpeed + '\'' + 204 "\nISO='" + ISO + '\'' + 205 "\nfocalLength='" + focalLength + '\'' + 206 "\nfileType='" + fileType + '\'' + 207 "\nphotoDate='" + photoDate + '\'' + 208 "\nfileSize='" + fileSize + '\'' + 209 "\nfileDimension='" + fileDimension + '\'' + Yeah. Its because I first added all the metadata in the toString, but seeing how all the metadata is a ridiculous amount of information I took it out again. Only did that after the rebase, so there shouldt be any difference between them really?
Edited by Lars Brodin Østbychanged this line in version 5 of the diff
58 59 @Column(name = "filedimension") 59 60 private String fileDimension; 60 61 62 @Lob 63 @Column(name = "allMetadata") 64 private String allMetadata; changed this line in version 5 of the diff
58 59 @Column(name = "filedimension") 59 60 private String fileDimension; 60 61 62 @Lob ahh no I only changed it in phpadmin
Edited by Lars Brodin Østby
94 99 return camera; 95 100 } 96 101 102 public String getAllMetadata(){ changed this line in version 5 of the diff
358 358 textToClean = textToClean.substring(0, textToClean.length()-2); 359 359 return textToClean; 360 360 } 361 362 /** 363 * Method for getting all metadata from an image 364 * @param file that will be checked 365 * @return metadata or an empty string if nothing was found 366 */ 367 public static String getAllMetadata(File file){ changed this line in version 5 of the diff
362 /** 363 * Method for getting all metadata from an image 364 * @param file that will be checked 365 * @return metadata or an empty string if nothing was found 366 */ 367 public static String getAllMetadata(File file){ 368 String allMetadata = " "; 369 try { 370 Metadata metadata = ImageMetadataReader.readMetadata(file); 371 for (Directory directory : metadata.getDirectories()) { 372 for (Tag tag : directory.getTags()) { 373 allMetadata += tag + " #"; 374 } 375 } 376 } catch (IOException | ImageProcessingException | NullPointerException e) { 377 logger.error("[x] Could not get information from file"); changed this line in version 5 of the diff
358 358 textToClean = textToClean.substring(0, textToClean.length()-2); 359 359 return textToClean; 360 360 } 361 362 /** 363 * Method for getting all metadata from an image 364 * @param file that will be checked 365 * @return metadata or an empty string if nothing was found 366 */ 367 public static String getAllMetadata(File file){ 368 String allMetadata = " "; 369 try { 370 Metadata metadata = ImageMetadataReader.readMetadata(file); 371 for (Directory directory : metadata.getDirectories()) { 372 for (Tag tag : directory.getTags()) { 373 allMetadata += tag + " #"; Nice:)
If you are interested, you can do this with
1- a StringBuilder for appending to a string in a loop to lessen the amounts of "loose parts"
2 - Use a flatMap from the Stream API. You then create a stream of Tag streams which you collapse into one stream, like this:
metadata.getDirectories() .stream() .map(Directory::getTags) .flatMap(tag -> allMetaData.append(tag).append("#"));
...if I remember correctly
Not sure if the stringbuilder works with streams.Edited by Eirik Steirachanged this line in version 5 of the diff
mentioned in commit 36e677fb