-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Added metadata reader for reading exif data #2581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@maskaravivek @nicolas-raoul Can you please review this PR. It will help in working out with #2542 |
import timber.log.Timber; | ||
|
||
@Singleton | ||
public class ReadEXIF { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason for using a verb rather than a noun (which is the convention for Java classes)?
I would suggest EXIFReader
.
|
||
} | ||
|
||
public Single<Integer> processMetadata(String path) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
javadoc
@nicolas-raoul I have made the changes. Kindly review :) |
Codecov Report
@@ Coverage Diff @@
## master #2581 +/- ##
=========================================
+ Coverage 2.77% 2.77% +<.01%
=========================================
Files 259 261 +2
Lines 12373 12451 +78
Branches 1117 1130 +13
=========================================
+ Hits 343 346 +3
- Misses 12003 12078 +75
Partials 27 27
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few minor things :-)
|
||
} | ||
|
||
public Single<Integer> processMetadata(String path) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
javadoc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added the doc for this just above the class declaration. Shall I put it above the function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both the class and the method need javadoc. At least say briefly what the method does, and what are the inputs and outputs of the method.
public class EXIFReader { | ||
@Inject | ||
public EXIFReader() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A common practice is to write // Empty
in empty methods so that readers know it is not a mistake :-)
try { | ||
readMetadata = ImageMetadataReader.readMetadata(new File(path)); | ||
} catch (ImageProcessingException e) { | ||
e.printStackTrace(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about logging the error to logcat? https://stackoverflow.com/a/8217563/226958
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With Timber I guess.
} | ||
if (readMetadata != null) { | ||
for (Directory directory : readMetadata.getDirectories()) { | ||
if (directory.getName().equals("Exif IFD0") || directory.getName().equals("Exif SubIFD") || directory.getName().equals("Exif Thumbnail")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put each equals
on its own line, and add at the end of the line a comment explaining where this kind of directory is usually found.
Otherwise future readers will have a very hard time knowing what it means.
Thanks! :-)
}); | ||
return Single.zip(zipResult,checkFBMD,checkEXIF, (zip,fbmd,exif)->{ | ||
Timber.d("zip:"+zip+"fbmd:"+fbmd+"exif:"+exif); | ||
return zip| fbmd| exif; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better put a space before |
.
For this kind of conventions a good read is https://www.oracle.com/technetwork/java/codeconventions-150003.pdf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thanks for the resource @nicolas-raoul :)
@nicolas-raoul I have made the changes. Kindly review :) |
// In case of internet downloaded image these three fields are not present | ||
if (directory.getName().equals("Exif IFD0") //Contains information about the device capturing the photo | ||
|| directory.getName().equals("Exif SubIFD") //contains information like date, time and pixels of the image | ||
|| directory.getName().equals("Exif Thumbnail")) //contains information about Image THumbnail like compression and reolution |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
about Image THumbnail like compression and reolution -> about image thumbnails like compression and resolution
Timber.d("zip:" + zip + "fbmd:" + fbmd); | ||
return zip | fbmd; | ||
}); | ||
return Single.zip(zipResult,checkFBMD,checkEXIF, (zip,fbmd,exif)->{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space after each comma
return zip | fbmd; | ||
}); | ||
return Single.zip(zipResult,checkFBMD,checkEXIF, (zip,fbmd,exif)->{ | ||
Timber.d("zip:"+zip+"fbmd:"+fbmd+"exif:"+exif); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space before and after each +
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Thanks for approving the PR @nicolas-raoul @neslihanturan @ujjwalagrawal17 |
Reading EXIF Directories Exif IFD0, Exif SubIFD, Exif Thumbnail if it does not contains any of these disaplay a warning to the user
Fixes #97 Avoid copyright violations
Changes Made