commons-app / apps-android-commons

The Wikimedia Commons Android app allows users to upload pictures from their Android phone/tablet to Wikimedia Commons
https://commons-app.github.io/
Apache License 2.0
1.03k stars 1.23k forks source link

Transform picture (crop/rotate/etc) within the app #1192

Open ujjwalagrawal17 opened 6 years ago

ujjwalagrawal17 commented 6 years ago

The app should have image editing features.

Desirable features:

Undesirable features:

Debated:

nicolas-raoul commented 1 year ago

@shankarpriyank Do you mean that LLJTran may be faster? If you mean something else, please post the facts here and be explicit, thanks :-) Also, where does the 15 seconds figure comes from? jpegtran takes around one second to transform a large picture.

shankarpriyank commented 1 year ago

@nicolas-raoul In this thread if you read the top-rated answer, a developer is telling that it is taking around 15 seconds for the transformation to complete. I did not test anything myself, just sharing what's written in that thread.

image

I guess I will try making a sample out and report out my findings.

shankarpriyank commented 1 year ago

Hey @nicolas-raoul I am making sample/poc app for lossless transformations, just wanted to confirm once if this issue can be fixed as a project under GSoC 23

nicolas-raoul commented 1 year ago

Hi @shankarpriyank, thanks for the question! There is an official GSoC task (making upload more reliable), but since you seem to already have experience in the non-trivial field of lossless transformations, you are welcome to create a proposal based on this GitHub issue. Thank you for your interest!

shankarpriyank commented 1 year ago

Hi @nicolas-raoul. I made a sample/poc app and tested it. The transformations are very fast, practically there is no delay. Although during the process of making that app, there is one challenge that I identified. We need to discuss the flow of the transformations or the permission handling. Basically with the security updates coming in android now if you want to edit any media file which is not of the app itself the app will need to ask for extra permissions(https://developer.android.com/training/data-storage/shared/media#update-other-apps-files). But there is no need for this permission if you do not want to modify the original file. We can just save a new transformed image. I also had a look at #2542 the pr seems really nice and I think we can follow the same approach to implement the crop feature. Summing it up we are looking at Crop/Rotate/Blur and we have an implementation strategy ready for Crop and Rotate.

Please let me know your thoughts

nicolas-raoul commented 1 year ago

@shankarpriyank

I am very happy to hear that performance is good!

About permissions: We already have the picture's full data, for instance we read its binary data to find out whether the picture was downloaded from Facebook or not. So I don't think permissions will be an issue to implement this feature.

Thank you for checking Vanshika's work! As you know, two additional challenges here will be to:

shankarpriyank commented 1 year ago

@nicolas-raoul Reading data is one thing and editing it is different if we want to transform the original image I think there will be permission issues coming up, please have a look at this link - https://developer.android.com/training/data-storage/shared/media#update-other-apps-files Sorry, I maybe wrong but can we crop images without bearing any loss?

nicolas-raoul commented 1 year ago

@shankarpriyank

The good news is that we do not need to open files in write mode. If we have all bits from the image, then we can for instance copy it to another array or temporary file, modify that array as much as we want, then upload that array to the Wikimedia Commons server (in other words: upload the modified file) with no permission issues.

can we crop images without bearing any loss?

Loss in the blurred part is acceptable, but loss far from the blurred parts is not acceptable. Please read this section to understand what is expected. This can be implemented this way:

  1. Split the JPEG image into many 8x8 JPEG images. Zero information is lost in this step.
  2. Blur only the blocks that that users wants to blur.
  3. Put all of the blocks back together. Zero information is lost in this step for non-blurred blocks.
  4. Update (or just remove if easier) the preview often embedded in the EXIF, as it still shows the private information.

If this sounds like too much work for a GSoC, feel free to split your GSoC proposal into two parts:

  1. Crop and rotate: Prototype, proper implementation, tests, documentation, merge.
  2. Blur: Prototype, then the rest as much as time allows.
shankarpriyank commented 1 year ago

Hey @nicolas-raoul I made a proposal on phabricator, I would be really grateful I you could provide me with some feedback