Bug 520498 - Krita crashes if I attempt to adjust an incorrect print size on a PNG
Summary: Krita crashes if I attempt to adjust an incorrect print size on a PNG
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: * Unknown (other bugs)
Version First Reported In: 5.3.1
Platform: macOS (DMG) macOS
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-05-21 17:54 UTC by Rich
Modified: 2026-05-23 01:43 UTC (History)
1 user (show)

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


Attachments
IPS crash report macOS logged after crashing out (132.00 KB, text/plain)
2026-05-21 17:54 UTC, Rich
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rich 2026-05-21 17:54:46 UTC
Created attachment 192525 [details]
IPS crash report macOS logged after crashing out

DESCRIPTION
I attempted to quickly open a PNG and add some text to it, but found that the text did not display when I attempted this several times.

On investigating, the PNG, which was around 1100x1000, reported a Print Size of around 60 million PPI.

I attempted to Scale Image to New Size, made sure adjust print size independently was checked, set it to something like 300 PPI, clicked Ok, and Krita crashed.

It hasn't done it again on repeat attempts, though, unfortunately. The IPS bundle macOS generated is attached.

STEPS TO REPRODUCE
1. Open PNG file that reports absurd PPI
2. Attempt to add a text layer.
3. Attempt to reset PPI to smaller value
4. Boom.

OBSERVED RESULT
Krita crashed.

EXPECTED RESULT
Image PPI value adjusted.

SOFTWARE/OS VERSIONS
Operating System (available in the Info Center app, or by running `kinfo` in a terminal window): macOS 15.7.4
KDE Plasma Version: N/A
KDE Frameworks Version:  N/A
Qt Version:  N/A

ADDITIONAL INFORMATION
Comment 1 vanyossi 2026-05-21 20:50:20 UTC
you ran out of memory crash. 60million does not seem to be a sane DPI, at least not for krita intended use.  I believe the text tool is working as intended, rendering the text in 'pt' sizes relative to the image reported DPI and pixels on screen.

Before adding text be sure to modify the image DPI (not the image pixel size, but the printing size) : Image -> Scale Image to New Size.., make sure "Adjust print size separatedly" is checked, and modfy the DPI to the desired amount, i.e. 150. Apply and then text should be manageable. I tested with a 6million DPI image and there was no crash. I was even able to add text, but I could not convert it to pixel data (it was extremely big)

If you can't use krita to change the DPI use another tool, like "sips" on the terminal: 'sips -s dpiHeight 150 -s dpiWidth 150 <path_to_image_file>'

60million is an absurd number (for printing on paper anyways), the max in krita allows to set is 10_000
Comment 2 Rich 2026-05-21 21:56:39 UTC
I suppose I'm surprised this is NOTABUG, given that I didn't generate the original image, and the original image appears to have no print size defined in its metadata, based on diffing imagemagick's identify -verbose on a before and after:

-  Units: Undefined
+  Resolution: 59.06x59.06
+  Print size: 28.9197x19.3024
+  Units: PixelsPerCentimeter

So at a minimum, defaulting to reporting an enormous value seems like a bug.
Comment 3 vanyossi 2026-05-22 02:01:19 UTC
In that case could you provide the faulty PNG? if it cannot be shared publicly you can email me directly at ghevan[at]gmail.com.
Comment 4 vanyossi 2026-05-22 02:01:51 UTC
chage status to waiting for info
Comment 5 vanyossi 2026-05-22 02:13:04 UTC
Thanks for the additional info, I was able to recreate the behaviour confirming the bug.

with image magick -> magick input.png -strip output.png, the resulting image will be missing the units metada which causes krita to report resolution as "62235566.405776" which I suppose is reading an undefined memory region as a number.
Comment 6 vanyossi 2026-05-23 01:43:32 UTC
Git commit 5f4234febac4261f2087b7c1a7e00e66783e7e8a by Ivan Yossi.
Committed on 23/05/2026 at 01:42.
Pushed by ivany into branch 'master'.

handle case for png with undefined resolution

M  +3    -1    libs/ui/kis_png_converter.cpp

https://invent.kde.org/graphics/krita/-/commit/5f4234febac4261f2087b7c1a7e00e66783e7e8a