# Lossless JPG Editing for Wikimedia Commons Android: Precise Crop, Rotation, and Privacy-Aware Blurring
**Name:** Jagadeeshwar Reddy Kota
**Email:** kota.jagadesh123@gmail.com
**GitHub:** https://github.com/kota-jagadeesh
**LinkedIn:** https://linkedin.com/in/jagadeeshwar-reddy-kota
**Country:** India
**Preferred Time Zone:** Indian Standard Time (IST, UTC +5:30)
**University:** Amrita Vishwa Vidyapeetham
**Course:** Bachelor of Technology in Artificial Intelligence & Data Science
**Availability for Google Summer of Code:** Full-time (42+ hours per week)
## Synopsis
### App
Wikimedia Commons is an Android application developed by the Wikimedia Foundation that enables users to browse, upload, and contribute media directly to the Wikimedia Commons repository using their mobile devices. Users can easily select images from their device gallery or capture photos using the camera and upload them to the platform. The app aims to simplify the media contribution workflow and make it easier for contributors to share freely licensed images with the Wikimedia ecosystem.
### Project
This project aims to implement advanced** lossless JPEG image editing** capabilities in the Wikimedia Commons Android App to enable contributors to safely edit images before uploading them, while preserving their original quality, metadata, and file structure. While the application already supports basic editing features such as cropping and rotation, these operations need to be improved to ensure that transformations remain fully lossless and do not alter the image data, metadata, or color information.
Through my prior investigation of Issue [[ https://github.com/commons-app/apps-android-commons/issues/6659 | #6659 ]], I conducted detailed testing on the current rotation pipeline, including multi-step rotation experiments and metadata comparisons using tools such as exiftool. This analysis revealed that the brightness shift observed after rotating images is caused by **Android’s ExifInterface.saveAttributes()** method, which rewrites the EXIF metadata block and removes the original ICC Color Profile. Because the color profile is lost, image viewers render the rotated image with a different gamma/brightness profile. Based on this investigation, the project will focus on implementing a rotation pipeline that bypasses this metadata rewriting behavior using **jpegtran** to preserve the original headers and maintain exact color fidelity.
A key design principle of this project is that all transformations should operate directly on the JPEG macroblock structure, ensuring that edits are performed without unnecessary loss of information and without increasing the file size. This approach guarantees that contributors can safely edit images inside the app without degrading their quality or altering their metadata.
To achieve this, the project will deliver the following core improvements:
* **Deliverable 1: 100% Lossless Crop & Rotate (Fixing Issue [[ https://github.com/commons-app/apps-android-commons/issues/6659 | #6659 ]])**
The existing crop and rotation features will be improved to guarantee fully lossless transformations. The rotation pipeline will be redesigned to preserve the complete JPEG metadata, including the ICC color profile, preventing brightness and gamma shifts. This involve bypassing Android’s ExifInterface metadata rewriting and using a lower-level JPEG transformation approach (**using jpegtran**) that keeps the original metadata headers intact.
* **Deliverable 2: Automated Privacy Detection (Issue [[ https://github.com/commons-app/apps-android-commons/issues/1192
| #1192 ]])**
To assist contributors in protecting privacy before uploading images, the project will integrate on-device computer vision using **OpenCV's** Deep Neural Network (DNN) module. OpenCV is a widely used open-source computer vision library that supports modern deep learning, based object detection while operating entirely offline.
Using OpenCV’s DNN module, the application will run lightweight pre-trained detection models to identify sensitive regions such as human faces and vehicle license plates. These models analyze the image and return bounding box coordinates for detected objects with high accuracy. Because the detection pipeline runs fully on-device, no images are transmitted to external services, ensuring strict privacy preservation and compliance with Wikimedia’s privacy requirements.
The detected bounding boxes will be presented within the editing interface and passed to the lossless image editing module. These coordinates will then be used to determine the corresponding JPEG macroblocks that must be modified during the lossless blurring stage.
* **Deliverable 3: Lossless Macroblock Blurring (Issue [[ https://github.com/commons-app/apps-android-commons/issues/190 | #190 ]])**
The project will implement lossless privacy-aware blurring by modifying only the specific JPEG 8×8 DCT macroblocks corresponding to detected sensitive regions (faces or license plates). Instead of recompressing the entire image, which would degrade quality and potentially increase file size, this approach manipulates only the relevant macroblocks while leaving the rest of the JPEG structure untouched. As a result, the final image retains its exact original quality, metadata, and file size while ensuring that sensitive regions are irreversibly blurred.
By integrating these capabilities directly into the Commons Android App, contributors will be able to perform essential edits, such as cropping, rotating, and privacy blurring, directly within the application before uploading media. This reduces reliance on third-party editing tools, prevents accidental image degradation, and lowers the barrier for mobile contributions to Wikimedia Commons.
**Issue Links**
- https://github.com/commons-app/apps-android-commons/issues/1192
- https://github.com/commons-app/apps-android-commons/issues/190
- https://github.com/commons-app/apps-android-commons/issues/6659
- Phabricator Task link: https://phabricator.wikimedia.org/T415446
**Possible Mentor(s)**
- Mentor: @RitikaPahwa4444 (Ritika Pahwa)
- Mentor: @Nicolas_Raoul (Nicolas Raoul)
**Have you contacted the mentors already?**
Yes