Skip to content
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

Lightweight EXIF orientation for network JPG/TIFF #1031

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

JohnWowUs
Copy link
Contributor

I took some of the comments in PR #692 into account and came with a new solution light weight (no dependencies) for EXIF support for network JPG/TIFF files. These integrate the changes made in PR #1021 to handle all EXIF orientations.

I had to add some new resources for the tests hopefully that won't cause any problems with Travis.

import java.io.IOException;
import java.io.InputStream;

public class ExifStreamReader {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not public, +final

@JakeWharton
Copy link
Collaborator

Lovely test cases!

@JohnWowUs
Copy link
Contributor Author

The tests works locally but not with Travis for some reason.

@JakeWharton
Copy link
Collaborator

I can try locally later tonight.

@@ -0,0 +1,41 @@
/*
* Copyright (C) 2013 Square, Inc.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2015

@JakeWharton
Copy link
Collaborator

The test fails locally for me. I'll add some logging to the parsing and see what's wrong at lunch.

@JohnWowUs
Copy link
Contributor Author

The res folder in the test folder should be resources. I accidentally pushed a commit with the unrenamed version.

@dnkoutso
Copy link
Collaborator

squash to one commit.

@dnkoutso dnkoutso added this to the Picasso 2.5.3 milestone May 21, 2015
@dnkoutso
Copy link
Collaborator

Holding on on this one for perhaps the next release. 2.5.3 is supposed to be a small release and its turning out to be pretty big.

@dnkoutso dnkoutso modified the milestones: Picasso Next, Picasso 2.5.3 Jun 10, 2015
@dkharrat
Copy link

@JohnWowUs I just tried your branch to test a similar issue I found, but it didn't work in that images are broken and don't load at all. I saw the following messages in the logs:

D/skia﹕ --- SkImageDecoder::Factory returned null

After investigating it, it seems like it's due to the InputStream already being consumed by ExifStreamReader.getOrientation.

if (stream == null) {
return 0;
}
MarkableInputStream markStream = new MarkableInputStream(stream);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't using a MarkableInputStream here irrelevant, since it's local to ExifStreamReader only and will be discarded at the end of the call. The InputStream provided by the caller will still have been consumed and is independent of MarkableInputStream. Instead, I think you want to find a way to maintain the original InputStream (perhaps best done by the caller?)

I believe this is the root cause of the issue I was having using your branch, where images don't load up.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MarkableInputStream is used to allow us to reset the Inputstream i.e. not have it consumed.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to build JohnWowUs:IFStream-EXIF branch, and have the same issue. It would be great, if you can fix it and merge into picasso.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JohnWowUs I see what you mean; I was under the impression that the MarkableInputStream maintains its own marker and resetting it just resets MarkableInputStream, but after looking at the code, I see that it also tries to reset the original InputStream.

However, it seems that it does not work (hence, why I'm seeing failures in decoding the images). I believe it happens when the downloader is UrlConnectionDownloader, since that downloader uses the InputStream provided by openConnection(), which doesn't seem resettable.

Can you also try it on your end to confirm?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use OkHttpDownloader. Also I use NetworkInterceptor, wich replaces original InputStream with new one, because original stream is encrypted and I need to decrypt it.

@JohnWowUs
Copy link
Contributor Author

@icesmith @dkharrat
I believe it should be fixed now. Could you test on your end?

@icesmith
Copy link

icesmith commented Jul 1, 2015

Great!, It works for me now, thank you @JohnWowUs

@dkharrat
Copy link

@JohnWowUs it also works for me now. Thanks for fixing it!

@Shusshu
Copy link

Shusshu commented Aug 26, 2015

Is this going to be included in 2.5.3 and good to merge?

phileo added a commit to phileo/picasso that referenced this pull request Apr 21, 2016
Lightweight EXIF orientation for network JPG/TIFF square#1031
@abhinavraj
Copy link

Any update on timeline for merging this?

@bychkovdmitry
Copy link

Any chance this is going to be merged soon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants