-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add crop feature #581
Add crop feature #581
Conversation
The widget is a simple rectangle that can be moved and resized. It keeps its position relative to the image if the image is resized.
This includes a method to calculate the geometry of the rectangle that would be cropped from the image and the according status module to display this information.
Added as a new method of the imtransform module. It is handled like any other transformation.
This will be useful for cropping with a given aspectratio.
We now display a size handle on each corner and, if the aspectratio is not fixed, one on each side.
The completion options show examples of valid aspect-ratios as well as the keep option.
Seems like the comparison of QCursor with elements in the Qt.CursorShape enum was added in Qt 5.10. Thus the comparison always returned False and the `moving` property was always False.
Oh wow, thanks a lot, that was super fast! Reading into your comments, I noticed I was an idiot in at least two ways ...
I'll try to figure these two out, and hopefully get the "old" state of crop running on your branch based on the current master. You could then continue with the second task, i.e. "look for and fix bugs" 😊 I'll try to be fast 🤞 |
We can use quite a few Qt methods directly here.
We now store the selected region in the coordinates of the scene (the actual image) which never changes size instead of storing fractions and mapping them to the image / scene manually. Qt provides functions to map between the coordinates anyway.
Realized using an additional overlay which paints a dark alpha color over the full image and then clears the selected rectangle.
Before it was possible to move the selection outside of the displayed image. Now the crop selection "snaps" on the borders.
* The color of the shaded unselected region is now configurable. * The default border color is now a transparent light gray, better matching the overall "shadened" look. * The crop.bg style was removed as the background of the selected region is always fully transparent.
About the number 2, I think it was renamed... At least I think I saw something like this while fixing the conflicts. Maybe there was some old code still using the |
Definitely seems to be the case, so either I forgot to commit or git is confused by the rename 😊 no matter what, the cherry-picking was straightforward, after you have done all the hard work. I pushed to There are a few simple linter / mypy errors, but those are fast to change. I noticed currently one is not allowed to zoom after |
Just merged About zooming while cropping, implementing it will probably be give us some trouble and may not worth the work... We can add that in another PR if needed. |
I did a fast test here and the crop is indeed working now! Just one thing I noticed, when the image have a white background, it is hard to find the squares used to resize the crop area... We could try changing it to some color that contrast with any color. Maybe black borders with white fill or something like that. For comparison, Firefox's screenshot feature uses some shadow around the circles to contrast with white background: |
Nice!! 🥳 That is definitely not a great look, good catch! If you like, you can play around with the styling, and commit your favourite option. The css that is applied as a Qt stylesheet is in the class definition of The firefox version does look great, but not sure how we would get shadows with Qt, that are not just offsets using QGraphicsDropShadowEffect 🤔 |
Some changes
For this one I just removed the
This one will probably require some refactoring...
Search for bugsI also did some testing... Seems to work pretty good, but also there aren't too much to check... We cannot run commands, use shortcuts or anything except Test codeLooking at GitHub seems that some code don't have test code, but I'm unsure I'll be able to create those. While I do have experience with python testing, my experience is with web systems, not desktop programs... Some directions might help. |
Thanks again, this is looking great!
Search for bugsSounds good to me 👍 TestsAs there are already a few tests related to crop, I am totally fine keeping it as-is. Improving coverage is always nice of course, but I wouldn't consider this breaking, especially as mouse-related stuff is always quite a hassle to get right and stable. AUTHORSFinally, if you like, please add yourself to the |
I've fixed the crop tests. By the way I needed to change Also added my name to the |
Thanks a lot, merged 🎉 This makes sense, thanks for catching! Well without you crop would still be dead in some ancient branch, this was certainly a lot of help! Definitely share that hope 😉 |
By the way I think we'll need to update the documentation about this (and also the new |
Oohhh there is something already! Nice, didn't notice that... I'll take a look more closely later and if I feel there is something missing I'll add it! |
Now that I've take a look at it, I think it is good as is. Short and concise. Straight to the point. No need to make it more verbose... |
Perfect 😊 Hint in case you ever work on the documentation in the future: this part of the documentation (commands, statusbar modules, settings, ...) is auto-generated from the code + docstrings, no need to edit any of the |
As discussed in #8 , I'm fixing the issues left in the
crop
branch.Update from master
For now, I merged
master
intocrop
. Did only a simple manual test, everything except the:crop
command seems to work as expected. I'll deal with that later.Conflicts
Most conflicts was
import
ones. Slightly easy to fix.But a conflict in
vimiv/imutils/_file_handler.py
was a little more tricky. The code bellow was added tovimiv/imutils/_file_handler.py
in@property changed()
But removed in master: 94dc2d5
After some investigation and debugging I moved/adapted that code to
vimiv/imutils/imtransform.py
in@property changed()
.Next steps
:crop
command work