Bug 463713

Summary: scaleImage modifies hidden guides and ignores passed xRes and yRes
Product: [Applications] krita Reporter: Daniel <dstout55>
Component: Resize/Scale Image/LayerAssignee: Krita Bugs <krita-bugs-null>
Status: CONFIRMED ---    
Severity: normal CC: halla
Priority: NOR    
Version First Reported In: 5.1.4   
Target Milestone: ---   
Platform: Other   
OS: Other   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Daniel 2023-01-02 03:37:33 UTC
SUMMARY

Note: I had to remove most of the code output because it kept telling me my message was spam..

I've noticed two issues related to Document::scaleImage:

1. Guides in the document are modified slightly even if scaleImage doesn't actually change the image size
2. The xRes and yRes specified in scaleImage are ignored, and 288 is used instead

STEPS TO REPRODUCE
Create a 1087 x 1828 document at 300 DPI and add a single horizontal and vertical guide.

Run this script:

OBSERVED RESULT
When guides are currently visible I get this:

Note that the DPI (xres/yres) becomes 288 instead of 300

When guides are hidden, I get this:

Note that the guides changed from [1716.0] [571.0] to [1647.36] [548.16]

EXPECTED RESULT
scaleImage should not modify guides just because they are hidden. The guides should presumably scale in accordance with the image size changing, but if the image size doesn't change, the guides shouldn't change either.

The DPI passed into scaleImage should be used in the returned document.

SOFTWARE/OS VERSIONS
Windows: 10

ADDITIONAL INFORMATION
Comment 1 Daniel 2023-01-02 03:38:08 UTC
Here's the script I'm referring to, run in Scripter:

doc = Krita.instance().documents()[0]
horGuides = doc.horizontalGuides()
verGuides = doc.verticalGuides()
print(horGuides, verGuides) 

clone = doc.clone()
print(clone.horizontalGuides(), clone.verticalGuides())
print(clone.width(), clone.height(), clone.xRes(), clone.yRes())

clone.scaleImage(1087, 1828, 300, 300, "Hermite")
print(clone.width(), clone.height(), clone.xRes(), clone.yRes())

print(clone.horizontalGuides(), clone.verticalGuides())
Comment 2 Daniel 2023-01-02 03:39:34 UTC
Here's a pastebin for the output I'm referring to.. Apparently this bug tracker really doesn't like numbers or square brackets or something..

https://pastebin.com/NyWkEUSt
Comment 3 Daniel 2023-01-02 03:44:43 UTC
Here's something strange:

If I set the guides as visible on the source document before cloning and then hide them immediately after cloning, then the guides do not get modified when the clone is scaled.

If I try calling setGuidesVisible(True) on the clone, however, even before calling scaleImage on the clone, the guides get modified.

It seems like something about the Document::clone() method treats guides differently depending on whether or not they're visible, and that difference affects a future scaleImage call?
Comment 4 Halla Rempt 2023-01-04 10:12:06 UTC
I'm not sure what's up, but I can confirm the results.
Comment 5 Halla Rempt 2023-01-04 10:13:38 UTC
It is not a regression: Krita 4.4.8 had the same issue.