Bug 431310

Summary: pasting a screenshot into krita leads to ugly artifacts
Product: [Applications] krita Reporter: tt <faqs>
Component: GeneralAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: ahab.greybeard, halla, tamtamy.tymona
Priority: NOR    
Version: 4.4.1   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: krita paste
gimp screenshot paste

Description tt 2021-01-08 14:36:11 UTC
SUMMARY

on linux mint pasting a screencap into krita leaves ugly artifacts

STEPS TO REPRODUCE
1. hit the print key and select "copy to clipboard" (on linux mint)
2. open a new file in krita
3. paste the clipboard in
4. do it 5-15 times until krita decides to paste the clipboard in without artifacts

OBSERVED RESULT
jpeg compression like artifacts

EXPECTED RESULT
crisp pixels in a 1:1 copy

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Mint

ADDITIONAL INFORMATION
after a ton of tries it works, so krita can do it, but somehow does not do it all the time
Comment 1 Tiar 2021-01-08 15:58:09 UTC
Are you sure you have a proper size for the new file? Can you please check if File -> New -> From Clipboard gives you better or the same results?
Comment 2 tt 2021-01-09 16:34:29 UTC
(In reply to Tymond from comment #1)
> Are you sure you have a proper size for the new file? Can you please check
> if File -> New -> From Clipboard gives you better or the same results?

doing what you suggested seems to give more consistent results, actually I tried a few times and saw no artifacts. But it is not the bug I reported, the bug is about pasting a screenshot from the clipboard into an already existing project. This is a workaround but no fix. I might have worded the bug description misleading, sometimes you just want to paste a screenshot into an existing project.

The project resolution does not matter anyways, pasting a screenshot from clipboard into a smaller project files just hides parts of the pixel data and you can move the resulting new layer around and reveal hidden pixels. somehow krita converts clipboard pixel data to jpeg and pastes it in? the same process works flawless with gimp under the same linux (mint).
Comment 3 Tiar 2021-01-09 17:32:06 UTC
Krita doesn't do anything with the clipboard data - and I don't see those artifacts on my screen. Can you please make a screenshot and then first paste into an existing project with a size bigger than the screenshot, and then use the File -> New -> From Clipboard method, then save both as PNG (important, since PNG is lossless) and attach here?
Comment 4 Bug Janitor Service 2021-01-10 04:33:56 UTC
Thanks for your comment!

Automatically switching the status of this bug to REPORTED so that the KDE team
knows that the bug is ready to get confirmed.

In the future you may also do this yourself when providing needed information.
Comment 5 tt 2021-01-10 20:21:06 UTC
I upgraded mint to 20.1 as of today and use krita 4.4.1 (and not 4.1.x that comes with mint) and I seem to not be able to reproduce this bug anymore.
But please keep this open for a few more days, in case it happens again I can post here of course. Just like it always is, as soon as you close this bugreport it will happen again, I'm pretty sure... :P
Comment 6 tt 2021-01-12 16:21:19 UTC
and it did it again, I had to exlain something wrong with blender and made a screencap and pasted it into krita, , even with a bigger canvas than my monitor and these artifacts happened:
https://i.imgur.com/dyy5YPk.png
after pasting it in for 7 times it pasted it in without these artifacts.
Comment 7 Ahab Greybeard 2021-01-13 11:51:04 UTC
They look like jpg artifacts. Does your screencap utility have the option to have .jpg/.png capture?

Can you try using GIMP and doing Edit -> Paste as New Image?
Comment 8 tt 2021-01-25 15:54:10 UTC
Created attachment 135169 [details]
krita paste

pasted into krita
Comment 9 tt 2021-01-25 15:54:49 UTC
Created attachment 135170 [details]
gimp screenshot paste

pasted into gimp
Comment 10 tt 2021-01-25 15:57:08 UTC
okay, since Mint 20.1 this bug happens way less than on 20.0, or maybe because I use the current Krita version and not the way outdated version from the mint package manager, but now it happened again.
pasted the screenshot into krita and have these jpg like artifacts, pasted it into gimp for comparison and it is smooth.
Comment 11 Halla Rempt 2021-01-25 15:59:45 UTC
Maybe the mint clipboard also has a jpg version of the clip.
Comment 12 tt 2021-01-26 14:20:12 UTC
maybe... maybe not...

I already asked on the mint forums but since I can paste the very same screenshot into gimp without quality loss it is either krita or how krita communicates with the default screenshot tool of mint or how it handles the clipboard data.

https://forums.linuxmint.com/viewtopic.php?f=47&t=336540
Comment 13 Halla Rempt 2021-04-16 09:00:04 UTC
Git commit 6bfa6009a5f3345c19b29b72bb5261284c8fbcfb by Halla Rempt.
Committed on 16/04/2021 at 08:59.
Pushed by rempt into branch 'master'.

Remove JPG from the list of supported clipboard image formats

Mint randomly puts a JPG in its set of images on the clipboard
in its screenshot tool. And if it's the first image in the set,
Krita will try to use it, which gives pastes with JPG artefacts.

Gimp doesn't accept JPG clips, which makes people think it's a bug
in Krita, while it's just Mint being dumb. Anyway, there's no
good reason to accept JPG clips, and I'm not sure why we ever did.

M  +1    -2    libs/ui/utils/KisClipboardUtil.cpp

https://invent.kde.org/graphics/krita/commit/6bfa6009a5f3345c19b29b72bb5261284c8fbcfb
Comment 14 Halla Rempt 2021-04-16 09:00:28 UTC
Git commit 7d4a06b6f09dd66ec9b854e1e3a69c2a345f7f23 by Halla Rempt.
Committed on 16/04/2021 at 09:00.
Pushed by rempt into branch 'krita/4.3'.

Remove JPG from the list of supported clipboard image formats

Mint randomly puts a JPG in its set of images on the clipboard
in its screenshot tool. And if it's the first image in the set,
Krita will try to use it, which gives pastes with JPG artefacts.

Gimp doesn't accept JPG clips, which makes people think it's a bug
in Krita, while it's just Mint being dumb. Anyway, there's no
good reason to accept JPG clips, and I'm not sure why we ever did.
(cherry picked from commit 62f37bfe2369a6a0abe597e44ae85c3ee8da99a3)

M  +1    -2    libs/ui/utils/KisClipboardUtil.cpp

https://invent.kde.org/graphics/krita/commit/7d4a06b6f09dd66ec9b854e1e3a69c2a345f7f23