-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Lossless Transformations(Rotate feature) #5252
Lossless Transformations(Rotate feature) #5252
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, great start! :-)
@nicolas-raoul Thank you, I am having a hard time trying to find a way to send the edited back to the upload screen. |
@nicolas-raoul can you do a quick review here, I was not sure where to add the helper functions. |
Hi @shankarpriyank sorry for the delay! I just uploaded this picture using this branch, rotating it and tapping "Save". Unfortunately the uploaded image is not rotated, as you can see, it is deeper than a preview issue. For testing you can just take pictures of streets or monuments ad rotate them first to an unnatural angle. Thanks! :-) |
No worries @nicolas-raoul, thanks for testing it, I will try finding to fix this |
Hi @nicolas-raoul can you test this branch again? |
I just uploaded https://commons.wikimedia.org/wiki/File:2007,_cliff_near_Rabat_in_Malta.jpg with your branch. The picture originally had the wrong orientation, but I corrected it using the One remark: The result image does not have EXIF anymore. Would you mind making sure that the EXIF is kept? It is vital metadata information of the picture, it can contain coordinates and exact date for instance, which are very important to use the picture in Wikipedia. Thanks a lot! |
How are you checking the exif data? is there a handy tool i can use to test it ? |
@nicolas-raoul can you please test again, the exif data should be retained now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somehow I get Failed to rotate image
now... I tried two different pictures, 3 times 90 degrees.
screen-20231007-225756.mp4 |
That's happening most probably because the image's encoding is not supported by lljtran(mostly happens huffman encoding), can you please try with some other images. |
The successful rotation I had mentioned at #5252 (comment) was with a picture taken by the same camera the same day, though, os I doubt it used a different encoding... I just tried with a picture taken by Pixel 7 Pro's stock camera, the error message does not appear but the picture is not rotated either. :'-( |
Done @nicolas-raoul |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I just caught these.
Once the Flamingo PR is merged (now waiting for #5339), I will ask you to rebase (or pull), and will review the code once more just in case, thank you for your understanding. :-)
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, is all of this whitespace needed? :-)
|
||
val animator = ValueAnimator.ofFloat(0f, 1f).setDuration(1000L) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single white lines is better within functions.
} | ||
btn_save.setOnClickListener { | ||
getRotatedImage() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove empty line before }
Hey! no worries at all. |
} catch (Exception e) { | ||
Timber.e(e); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove empty lines here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove 1 line
Actually, would you mind:
This will allow us to review all of your changes clearly (not mixed with other Flamingo-related changes). Maybe we can even merge this into the |
I made the pr, but in the first look it also seems to have unrelated changes. |
The main branch now supports Flamingo :-) |
Would you mind rebasing or pulling from main, then checking the difference and possibly donig a bit of clean-up? Then ask for a review. :-) |
# Conflicts: # app/src/main/java/fr/free/nrw/commons/upload/UploadActivity.java # app/src/main/java/fr/free/nrw/commons/upload/mediaDetails/UploadMediaDetailFragment.java
I pulled the changes from main, and now the pr looks quite clean to me. |
Any idea why a unit test fails? |
Nope, had a look at the logs, I could not really infer much from it apart from
|
|
@nicolas-raoul its fixed now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor
app/src/main/java/fr/free/nrw/commons/upload/mediaDetails/UploadMediaDetailFragment.java
Show resolved
Hide resolved
Intent intent = new Intent(getContext(), EditActivity.class); | ||
intent.putExtra("image", uploadableFile.getFilePath().toString()); | ||
startActivityForResult(intent, REQUEST_CODE_FOR_EDIT_ACTIVITY); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove 2 empty lines
@Override | ||
public void onEditButtonClicked(int indexInViewFlipper){ | ||
view.showEditActivity(repository.getUploads().get(indexInViewFlipper)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove 1 empty line
} | ||
|
||
init() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove 1 empty line
@OnClick(R.id.edit_image) | ||
public void onEditButtonClicked() { | ||
presenter.onEditButtonClicked(callback.getIndexInViewFlipper(this)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove 1 empty line
presenter.onEditButtonClicked(callback.getIndexInViewFlipper(this)); | ||
|
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove 1 empty line
} | ||
|
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove 1 empty line
app/src/main/java/fr/free/nrw/commons/upload/mediaDetails/UploadMediaDetailsContract.java
Show resolved
Hide resolved
android:text="@string/menu_save_categories" | ||
android:textColor="@android:color/white" /> | ||
</LinearLayout> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove 2 empty lines
@nicolas-raoul i guess all of them are fixed now |
app/src/main/java/fr/free/nrw/commons/upload/mediaDetails/UploadMediaDetailFragment.java
Show resolved
Hide resolved
} catch (Exception e) { | ||
Timber.e(e); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove 1 line
fixed |
Huge congratulations @shankarpriyank for adding this lossless rotation feature to the app, as well as setting the foundation for other lossless transforms. |
Thank you so much for your kind words! |
Description (required)
Made simple changes to initiate the editing feature in the app, right now the UI can only facilitate rotating the images, the rotated imaged are written in the download directory, but how to propagate the images back to the uploads is something I am trying to figure rn, and I would appreciate any help with it.
Also cause I have merged #5220 in this branch so please ignore the changes that were made in that pr.
Please let me know what do you think about the changes, I know that a lot of improvements can be made but I am focusing on getting things running first, let me know if you want me to do anything differently