Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

bring back duplicate searching and square thumbnails, performance improvements, crop improvements from shawn, and other minor stuff #262

Merged
merged 28 commits into from
May 21, 2020

Conversation

sandsmark
Copy link
Collaborator

No description provided.

ec1oud and others added 28 commits May 21, 2020 16:35
They will be useful during the interactive rotation feature when a user
tries to horizontally or vertically align some feature in a photo.
Hold control-shift while dragging near the right edge, and it will
rotate the image continuously while you drag up and down.  On release,
it transforms the image in memory.  Then the rotation can be saved to
the file, as with other transformations.

Rotation must be stored in floating point: a one-degree increment is
not nearly accurate enough for rotating photos that were taken or
scanned crooked.  QTransform::rotate() takes it as qreal anyhow.

Since QWidget (and QLabel) does not have an arbitrary rotation
feature (unlike QGraphicsItem and QQuickItem), we need to have
the actual image widget larger than the image so that rendering
doesn't get cut off while the image is being rotated.  So it can't
be a QLabel anymore; it needs to be a custom widget that can call
QPainter::rotate() before painting the image.

Warning: this patch introduces problems with zooming and scrolling.
It works well when the window is larger than the image being shown
so that scaling is 100% and there is space around the edges to show
the rotation.  But just as ImageWidget has a rotation property,
it probably needs to have a scale property too, to handle the
control-mousewheel zooming properly.  And of course it needs to
have bigger geometry when you zoom, but I think that's done outside
so far.
When batch-processing a directory of images, it's convenient to make the
Save action save files to another directory, to avoid overwriting the
original images (which I would prefer to chmod a-w, just to be sure).
Control-S will save a copy to the new directory rather than overwriting
whenever Settings::saveDirectory is defined; but this setting is not
persistent, because I would prefer to set it each time before starting
a batch.
…error

If it happens once in a batch, it's likely to happen again.  This setting
is localized and non-persistent.  qWarning() showing the actual error message
from Exiv2 is more helpful anyway.
When doing repeated work (or testing) into a particular output directory
it's nice to be able to specify it on the command line.
This will help to implement the feature to select by brightness,
and help the user decide how bright is too bright or too dark.
The method chosen is to scale each thumbnail to a 1x1 pixel image,
and take the greyscale value of that pixel.  Brightness is in the
range 0..1 (QImage uses 0..255 but that's not very future-proof,
and users probably prefer to think in terms of percentage anyway).
When doing batch processing, it's nice to be able to find all
the images which are too bright or too dark to be useful.
After selecting them, it's easy to delete them.

We need to know the brightnesses of all the images to do this.
The way chosen here is to preload all their thumbnails.
But that can take some time, so we show a progress dialog, with
the ability to cancel.  The dialog is not modal, because it appears
that loading thumbnails does not interfere with other usage of the
application, so it can be done in the background.
After rotating and cropping one image, it's possible to select a series
of images and repeat the same rotation and crop on all of them.
Settings remembers the crop and the rotation.  ImageView re-applies
them if Keep Transform is turned on, so that after you go to the next
image, you can visually re-confirm that's what you want and then hit
Control-R to rotate and crop the new image the same as the last one.

With the previous approach there were a couple of downsides:
if Settings::cropLeft, cropTop etc. are set back to zero, it ironically
means that "Keep Transform" results in the crop being forgotten
rather than kept.  Also, applying it immediately to the QImage
without confirmation means that you can't see anymore what that
next image would have looked like without crop and rotation:
it's too destructive (in memory at least) and there's no undo.
When you are interactively looking at one image at a time, I think
the visual confirmation is a good feature.  If you want to
automatically re-apply the transform without confirmation, you can
now use batch mode for that.

Now both the crop rubberband and ImageWidget::rotation() are
equally ephemeral, and Ctrl-R applies the crop and rotation both
to the image and to Settings.  Settings remembers the crop and
rotation while we transition from one image to the next, both
manually and in batch mode.  So the menu item needed renaming too:
instead of Crop to Selection it's Apply Crop and Rotation.
So far there is no direct-entry UI, but at least with enough manual
dexterity it's possible to repeat the same-sized crop on a different
image in a different position.
Sometimes the mouse (touchpad) isn't accurate enough for fine adjustments.
Arrow key events aren't getting here for some reason, but for now the
vi-style hjkl keys will do the trick.
@oferkv oferkv merged commit 9995384 into oferkv:master May 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants