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

Automatic conversion of image files to .jpg prior to submission to Briefcase or Aggregate. #1173

Open
danielsteward opened this issue Jun 19, 2017 · 13 comments

Comments

@danielsteward
Copy link

Collect v1.7.1 (but all versions as far as I know), Android v6.0.1, Fairphone 2.

Problem description:
Collect renames all image files to .jpg extension whatever the android device creates and is submitting only .jpgs to Aggregate

Steps to reproduce the problem:
Create an image other than a on the phone and attempt to add it to a form. The image is renamed with a .jpg extension

Expected behavior:
Possibly this IS the expected behaviour although this is connected to other issues with Briefcase and Aggregate and needs to be rationalised across the board. See issue getodk/briefcase#5 and getodk/briefcase#33

If anyone knows what the original purpose of this conversion to .jpg is please comment.

@danielsteward
Copy link
Author

The conversion takes place in the class collect\android\activities\FormEntryActivity within the methods onActivityResult() L 629 and saveChosenImage() L 819.

@danielsteward
Copy link
Author

OK, update.
I am not sure that this is a bug as such. With my testing of how Collect, Briefcase and Aggregate work together it seems that Aggregate can only handle jpg image types. If you try to push an instance from Briefcase to Aggregate, substituting a gif for a jpg the image doesn’t display in Aggregate. And Collect simply converts an image to a jpg whatever the image type chosen.
So we can either work with this or amend Aggregate so that it can handle image types other than jpgs. I’m not sure where to take this next. Any ideas team?

@yanokwa
Copy link
Member

yanokwa commented Jul 7, 2017

@danielsteward Thanks for the great detective work!

@mitchellsundt @wbrunette Is it true that Aggregate can only handle JPGs? I'd love some insight as to why that is the case and what potential workarounds are.

@mitchellsundt
Copy link
Contributor

Aggregate can handle any content, but when displaying the little thumbnails on the Submissions pages, it executes this codepath https://github.com/opendatakit/aggregate/blob/master/src/main/java/org/opendatakit/aggregate/servlet/BinaryDataServlet.java#L213 to scale down the image.

And that prevents handling anything other than JPG.

The underlying library might be able to support more file formats. The code is here: https://github.com/opendatakit/aggregate/tree/master/src/main/java/org/opendatakit/aggregate/util with different implementations for AppEngine (using a Google service) and Tomcat. The Tomcat code uses this library: https://github.com/opendatakit/aggregate-components/tree/master/TomcatUtils which uses a hacked imageio library with a bunch of licensed / proprietary format handlers removed https://github.com/jai-imageio/jai-imageio-core

@mitchellsundt
Copy link
Contributor

And collect shouldn't have any restrictions on file types.
I don't think you're reading the code correctly if you see anything like that.

@yanokwa
Copy link
Member

yanokwa commented Jul 7, 2017

@mitchellsundt Collect doesn't have restrictions on file types, but it does rename any image to jpg before uploading. https://github.com/opendatakit/collect/blob/master/collect_app/src/main/java/org/odk/collect/android/activities/FormEntryActivity.java#L656 is the relevant line of code.

This is bad behavior on the part of Collect and I think we should probably fix it. But it does break Aggregate, so we'd need to get a fix in place first. With the information you provided, would this be contributor friendly?

@danielsteward
Copy link
Author

I'd be happy to take something like this on if I have guidance from a Java master. That is exactly what I'm looking for here to improve my coding and expand my knowledge. Especially if it is with ODK.

@kusaasira
Copy link

True. I support this.

On the other hand, is there a possibility to manipulate the images from BLOB to a url that the image can be saved in a directory on the file server? Some manipulation of the sort?

@mathieubossaert
Copy link

The possibility to store images files in a directory on the server should be great, or maybe just a script to easily convert blob to file. At the moment it's not so easy to get and use collected images.

@yanokwa
Copy link
Member

yanokwa commented Aug 4, 2017

@kusaasira @mathieubossaert Agreed that easier access to images on Aggregate would be a nice thing, but it's not relevant to this issue. If you'd like to see this discussed, please file an issue at https://github.com/opendatakit/opendatakit/issues

@mathieubossaert
Copy link

Sorry for the "pollution", here is the new issue : getodk/getodk#1313

@kusaasira
Copy link

@yanokwa @mathieubossaert the issue getodk/getodk#1313 was closed unanimously hence I thought we would get a better way forward from here.

@lognaturel
Copy link
Member

@kusaasira This issue is about keeping PNGs submitted by Collect as PNGs instead of changing their extension to jpg. The discussion of image handling on Aggregate is now at getodk/aggregate#164.

@grzesiek2010 grzesiek2010 self-assigned this Jul 14, 2022
@grzesiek2010 grzesiek2010 removed their assignment Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants