Bug 432036 - Crop Tool: Aspect ratio lock ignored when trying to resize cropped area beyond image border
Summary: Crop Tool: Aspect ratio lock ignored when trying to resize cropped area beyon...
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Tools (show other bugs)
Version: 4.4.2
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: vanyossi
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-24 13:43 UTC by Simon Repp
Modified: 2021-03-10 13:36 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Repp 2021-01-24 13:43:22 UTC
SUMMARY

The Aspect ratio lock is ignored when trying to resize a cropped area beyond the image border. 

Note that the steps and results described below can be observed both in the horizontal and vertical domain - i.e. by interchanging both portrait/landscape and width/height in the steps below, the problem can be reproduced on either axis.

Video Demonstration:

https://fdpl.io/locked_ratio_crop_overflow.mp4 (<400kb, 28sec)

(Note: In the video also pay attention to the aspect ratio jumping around while resizing the cropped area *without* aspect ratio lock enabled - maybe symptomatic of why the problem happens *with* the lock, also UX wise feels a bit unclean that it jumps around, although functionally it poses no problem as it jumps back)


STEPS TO REPRODUCE

1. Have open a document with a portrait-type aspect ratio
2. Select the Crop Tool - make sure "Grow" is disabled
2. Begin a crop with a *locked landscape-type aspect ratio* (e.g. 1.9)
3. Resize the cropped area in width, going beyond the image border

OBSERVED RESULT

The height of the cropped area increases and increases, even when the cropped area already spans the full width (and thus does not expand anymore), therefore the locked aspect ratio is not maintained anymore at some point

EXPECTED RESULT

As soon as the cropped area spans the full width of the document it should not grow anymore, neither in width, nor in height - thereby the aspect ratio would be maintained, as the lock dictates.

SOFTWARE/OS VERSIONS

Observable in master as well as in latest released Krita (4.4.2)

ADDITIONAL INFORMATION

As far as I can see Dmitry has implemented an abstract rectangle class that handles these resizing constraints (width/height/aspect ratio), I haven't studied it in detail but I suspect the way it is implemented maybe doesn't cover this specific case documented here (yet) (hopefully the implementation model can cover it).

I might potentially look into a fix for this myself if available hands on the team are short for this, but either way I think it would be good if someone in the krita team first triages this, either laying out a preferred approach for a fix (if it needs larger changes) or maybe even fixing it right away if it happens to be a quick fix. :)
Comment 1 tomtomtomreportingin 2021-01-25 01:17:44 UTC
I can reproduce this.
Comment 2 tomtomtomreportingin 2021-01-25 01:28:25 UTC
Also, the bug itself isn't a regression from what I can see, but maybe it's worth noting that in pre-4.2.8, the buggy behavior doesn't happen if you expand the crop towards and past the image border. It doesn't happen otherwise.
Comment 3 tomtomtomreportingin 2021-01-25 01:39:33 UTC
(In reply to tomtomtomreportingin from comment #2)
> It doesn't happen otherwise.

Uh, typo, it does happen, sorry.
Comment 4 Dmitry Kazakov 2021-03-10 13:36:51 UTC
Git commit efcd37828b5edc463637bd9bd3d0340189635b67 by Dmitry Kazakov, on behalf of Santhosh Anguluri.
Committed on 10/03/2021 at 13:36.
Pushed by dkazakov into branch 'master'.

Crop Tool: Aspect ratio lock ignored when trying to resize cropped area beyond image border

This commit restricts the size of the crop area as soon as any of its side
reaches the limit of the image.

M  +28   -6    plugins/tools/tool_crop/kis_constrained_rect.cpp

https://invent.kde.org/graphics/krita/commit/efcd37828b5edc463637bd9bd3d0340189635b67