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.02k stars 1.23k forks source link

Create Kotlin Multiplatform (KMP) package of jpegtran (lossless JPEG transformations) #5386

Open nicolas-raoul opened 11 months ago

nicolas-raoul commented 11 months ago

jpegtran is a library for lossless JPEG transformations, available mostly as C source code. We want to use it to implement lossless crop and other lossless transforms.

However, the app must still be easily buildable by newcomers who just have a basic Android Studio (and thus can't compile C code).

The goal of this issue is to build (or find if by chance one is already available) a package based on Kotlin Multiplatform technology embedding jpegtran, and offering JPEG transformations that can be used from a Kotlin Android app. Please create a different GitHub project for this task. Any volunteer? Thanks! :-)

Tagged "good first issue" not because it is easy, but because no knowledge of Commons is needed.

psh commented 11 months ago

Kotlin multiplatform will let you pull the C code in and make it accessible to Kotlin/Native but I am pretty sure you will still need to use JNI and the Android NDK if you want to access the code from the main Android source-set. That said, you should be able to create a project and provide an AAR that the rest of the app can use if you configure things as a library project.

nicolas-raoul commented 11 months ago

@psh

The idea would be to have a separate GitHub project whose goal is to produce a library that offers these transformations.

Our Commons app would only import that library (like any other external library, presumably through build.gradle) and use the methods. Hopefully building the Commons would just require Android Studio.

Does that sound like a good plan? 🙂

psh commented 11 months ago

The separate AAR library published as a maven/gradle dependency would definitely be easy to use & transparent to the casual developer of the commons app. 👍

shashankiitbhu commented 10 months ago

Can I take on this issue? @nicolas-raoul could you assign it to me?

nicolas-raoul commented 10 months ago

@shashankiitbhu It is yours! Please let us know about your progress once per week or so, thanks a lot! 🙂

shashankiitbhu commented 10 months ago

Hi @nicolas-raoul I am having difficulty with implementing jpegtran library in KMP , also there isn't any android or KMP library already available for this. However, there is a library in java for lossless JPEG transformations - https://github.com/k3b/LosslessJpgCrop/tree/master

nicolas-raoul commented 10 months ago

@shashankiitbhu I am familiar with the project you linked to, but I am not sure whether the underlying Facebook Spectrum library can be used to implement near-lossless blurring.

@shankarpriyank What do you think? 🙂

shankarpriyank commented 10 months ago

Had a quick glance, could not find anything related to blurring in the Spectrum library. But on the good side, I was struggling a bit with the crop feature and I am pretty sure that I am gonna get all the help I needed from this project

nicolas-raoul commented 10 months ago

@shankarpriyank

If Spectrum has a method to losslessly merge several JPEGs, then we can use it.

Please note that k3b's app is licensed under GPL, so we can't copy its code to our Apache-licensed app.

shankarpriyank commented 10 months ago

@nicolas-raoul

If Spectrum has a method to losslessly merge several JPEGs, then we can use it.

Sorry, I did not get it.

Please note that k3b's app is licensed under GPL, so we can't copy its code to our Apache-licensed app.

Yup, What I meant to say was that, k3b is a nice application which has a cropping feature, and cause it's open-source, I can take inspiration from its code to implement the cropping feature in the commons app. Some parts of the code may be quite similar but I guess that wont be an issue.

nicolas-raoul commented 2 months ago

@shashankiitbhu I unassign for now, but if you are you still working on this, please let us know. If no answer, someone else may be assigned to it. Thanks a lot. :-)