-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Support EXIF orientation for network JPG/TIFF #692
base: master
Are you sure you want to change the base?
Support EXIF orientation for network JPG/TIFF #692
Conversation
@@ -34,6 +42,7 @@ | |||
|
|||
private final Downloader downloader; | |||
private final Stats stats; | |||
private static Boolean hasImaging; |
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.
This should be at the top, boolean
, should be final
and should be initialized by a purpose-built function.
This functionality will need tests. |
Sure, I saw a comment this comment that discouraged me from doing all the work up front, but happy to do it if there's even a little interest. |
Thanks for the feedback - I'll revisit this tomorrow. |
Well the Sanselar jar alone is 5x the size of Picasso so you can see why we can't fully support things like that with a hard dependency. Not sure how large the commons version of it will be. I'd really like to see what it'd take to build an EXIF parser on top of Okio and embed that. If we wanted to get fancy we could build is as a pluggable system into the bowels of Picasso so that it could stand as its own add-on module (like the Pollexor one). |
I changed the dependency to Sanselan until Commons Imaging is finalized. Also, I spent some time thinking about how to test this - I noticed that the functionality is not tested on FileRequestHandler either. We can either manually construct the EXIF data using Sanselan (which I tried, and was more trouble than it was worth), or just include a small image and convert that to a stream to use in a mocked downloader. |
This post on StackOverflow (http://stackoverflow.com/questions/5468098/reading-exif-data-from-byte-array-in-android) points to a very simple Exif orientation extractor that google uses in com.android.Camera. Maybe this could be added to have a very light-weight Orientation extractor for JPEG's. |
I think an issue with this approach is that it requires the entire byte[] to sit in memory to determine the orientation which would be really inefficient for an edge case. This approach only reads the EXIF bytes and then resets the stream back to its original position. |
In the Gallery2 AOSP app there is an ExifParser class that is much more robust than the old one I posted above. This one seems to use an InputStream and seeking to extract the data. The whole exif package is here: Something like this might be a good drop-in. It'd be much smaller than including all of Sanselan/Commons Imaging. |
Great, nice find. |
The latest camera app actually uses that too. This is an updated version of the original file, but uses the newer Exif library. |
https://github.com/billylindeman/picasso/tree/billylindeman/embed_exif_parser_network_rotation It works, but right now it tries to read all exif tags. Definitely a good starting point for something light-(er) weight though. |
I am cleaning up all 2.4 issues. This one I'd like to take but has no tests. I can't accept this for 2.4 without tests. |
There are no tests for file:// rotation either, though. I spent a good amount of time trying to come up with a way to test it without using an actual image but didn't have any luck. @billylindeman do you want to make a PR with your code and try to write some tests? |
Newbie question: how would code calling Picasso access the EXIF orientation that was read by this pull request? |
You wouldn't. It's transparent to you. On Wed, Apr 15, 2015 at 1:52 PM Phileo [email protected] wrote:
|
ok, let me try this from another angle... |
We have no way to do that. See #639. |
thanks for that nugget of info, I think that might be able help me |
Forgive my ignorance, but I've added tests for the network exif orientation support in my fork of Picasso, and I'd like to submit it as a PR to the timehop repo, but I'm not sure how to do that across forks. The changes are here, please feel free to pull them if they look helpful, or tell me how I can submit them to update the PR. |
Any update? |
Uses commons-imaging to determine orientation (only if it's on the classpath, it's an optional dependency). Tests intentionally omitted for now, happy to add them if you want this feature.
Since commons-imaging is still at 1.0.0-SNAPSHOT I had to temporarily add the Apache snapshot repository but this API hasn't changed since it was brought into commons.