SUMMARY On the Wayland session, taking a rectangular region screenshot with Spectacle, the resolution is always incorrect, and the quality is bad. This affects both scaled and non-scaled displays. This issue is specific to region screenshots and "Capture Entire Desktop" screenshots. All other screenshot types (Active Window, Current Monitor, Window Under Cursor) all work fine. These are my issues with Rectangle Region screenshots: - Spectacle may show a resolution of over 5,000 pixels in width and almost 3,000 pixels in height on a 3840x2160 display (scaled to 150%) in the Resolution Preview Box when selecting a region. However this issue happens regardless of whether the display is scaled. - On the scaled display, Rectangular Region screenshots have this slightly jpeg-like outline around them as if they are compressed. Perhaps this is related to some kind of OpenCV upscaling? - On a 1920x1080 display, selecting close to the full size of the display with a Rectangular Region will show close to 3840x2160. With enough precision I could probably save an exact screenshot as 3840x2160. - Despite the resolution being wrong here, the actual image quality is better than on the scaled display. It just looks a bit overly sharpened and of course too big (in terms of resolution and filesize). - As of Plasma 6.0.5, the shown resolution on this Preview Box *is actually* the resolution the image is saved as. However, this resolution is not correct, this is not how many pixels are selected. It is also worth noting that when taking a "Capture Entire Desktop" screenshot, the resolution of one 1920x1080 display is actually 3840x2160. The resolution of the scaled display is 5120x2880. If you multiply these values by 0.75, you get 3840x2160. Perhaps this is relevant? I would also like to mention in case there is any confusion, I am not taking region screenshots across displays. This is a single region screenshot on a single display. STEPS TO REPRODUCE 1. Take a region screenshot with Spectacle. 2. The saved resolution is incorrect. 3. As well as this, a. On scaled displays, the image quality is poor. b. On non-scaled displays, the resolution is wrong. OBSERVED RESULT Spectacle saves Rectangular Region and Capture Active Window screenshots with the incorrect resolution and poor image quality on both scaled and non-scaled displays. EXPECTED RESULT Spectacle saves all screenshot types with the correct resolution and correct quality. Cropped Active Window screenshots and region screenshots of that cropped area should look identical. This was the behaviour in Plasma 5.27 if I recall. SOFTWARE/OS VERSIONS Linux/KDE Plasma: 6.9.3 Linux Zen KDE Plasma Version: 6.0.5 KDE Frameworks Version: 5.2.0 Qt Version: 6.7.1 ADDITIONAL INFORMATION My screenshots are saved as PNG with 90% compression quality.
For "Frameworks Version", I meant to say 6.2.0.
I also have this problem. The screenshot is blur when the screen is scaled to 125%.
Can you post an image of the "bad" quality screenshots and the screenshot image files themselves? You can take a screenshot of spectacle using spectacle with by running `spectacle -i` in the console.
Right now, the expected behavior for All Screens and Rectangular Region (requires an image of all screens before making a selection) is this: With one scale factor, combine all screen images into one image with the given scale factor. Quality an image size should be accurate to what the user sees. There are a few exceptions, but those shouldn't apply to your case. With multiple scale factors, the highest scale factor rounded up to the next integer is used. This has the following benefits: - Screen images with integer scale factors remain crisp, event when fractional scaling is used on some screens. - Screen images with fractional scales should have decent quality too, but they can never be perfect. - Relative screen image positions and sizes match the relative screen positions and sizes set in the Display Configuration KCM. *Rounding up* the scale factor is not necessarily required for this. I'm mentioning it because it's important and it affects what kinds of scaling operations you can make look good. This has the following downsides: - A region screenshot entirely within a single screen is unnecessarily large. This can be improved with https://invent.kde.org/graphics/spectacle/-/merge_requests/372. - A region screenshot or all screens screenshot with multiple screens must be a larger size than the logical size. We have to make tradeoffs and trading file size for quality seemed acceptable. In my testing, there were no obvious issues with quality compared to other methods when using different combinations of fractional scales or integer scales.
*** Bug 488028 has been marked as a duplicate of this bug. ***
Hello Noah, while reading your detailed description for how it works (thanks!) I was waiting for THIS moment: - A region screenshot entirely within a single screen is unnecessarily large. This can be improved with https://invent.kde.org/graphics/spectacle/-/merge_requests/372. That's exactly what we need I think. I honestly consider screenshots spanning several displays at different scale factors to be kind of an edge case. But whenever the area to capture (with "this display only" or rectangular region mode, doesn't matter) stays WITHIN the boundaries of a given display, that display's scale factor should be used. Achieving that behavior IMO would cover 99% of the cases. Multi-display screenshots with mixed scaling factors...you're looking at compromises, and I guess that's fine. (I'm the reported of 488028 BTW, so make sure to check - and save? - the attachment there before it expires, if you haven't already) I see that this has been put to NEEDSINFO, but I wonder if it should rather be CONFIRMED, since a MR#372 you mentioned is open to fix the "common" case, if I understand correctly? Thanks! :)
> Can you post an image of the "bad" quality screenshots and the screenshot image files themselves? You can take a screenshot of spectacle using spectacle with by running `spectacle -i` in the console. I can upload a rectangle region screenshot from my scaled display, which has poor quality. That part is no problem. I'm not sure what you're asking in the second part, though? Do you want me to take a screenshot of Spectacle taking a rectangle region screenshot, that is, initiate a region screenshot and then take a screenshot of Spectacle in this state? > Screen images with fractional scales should have decent quality too, but they can never be perfect. What type of screen images are you referring to here? Single-window screenshots (Active Window, Window Under Cursor) and Current Monitor screenshots currently look perfectly fine on scaled and non-scaled displays and have the correct resolution. If there is a trade-off, I would say it is far better than "decent", more like "unnoticeable" :-) Windows in Current Monitor screenshots look identical in quality to a single-window screenshot of the same window. > - A region screenshot or all screens screenshot with multiple screens must be a larger size than the logical size. We have to make tradeoffs and trading file size for quality seemed acceptable. There is no way to just stitch the images together here with the same quality they have using Current Monitor screenshots? >
Created attachment 170190 [details] Region Screenshot - YouTube [Poor Quality]
Created attachment 170191 [details] Current Monitor (Cropped) - YouTube [Good Quality]
Created attachment 170192 [details] Region Screenshot - Panel [Poor Quality]
Created attachment 170193 [details] Current Monitor (Cropped) - Panel [Good Quality]
I have provided four screenshots of two different scenarios to illustrate the bad quality. I recommend saving the images and zooming in using a tool such as Gwenview which doesn't filter the images. Viewing them in Firefox, at least for me, softens the images and if you zoom in they don't become pixelated. The Region Screenshots were taken on a 3840x2160 display scaled to 150%. The Current Monitor screenshots are cropped down to be close to the Region Screenshot. This is my current workaround; Current Monitor / Single Window screenshots that I crop down to a specific region. The Region Screenshot image screenshots have incorrect resolutions as well. The Current Monitor cropped screenshots have the correct resolution. - Scenario 1: YouTube Feed - Region Screenshot: Poor Quality (look around text, there is some sharpening/artifacting) - Current Monitor Screenshot: Good quality (text looks normal, image quality is either not dampened at all or it is virtually unnoticeable) - Scenario 2: Area of Panel - Region Screenshot: Poor Quality - Current Monitor Screenshot: Good quality (compare the quality of the icons in the taskbar, they have a noticeably worse quality in the Region Screenshot).
(In reply to Eamonn Rea from comment #8) > Created attachment 170190 [details] > Region Screenshot - YouTube [Poor Quality] (In reply to Eamonn Rea from comment #9) > Created attachment 170191 [details] > Current Monitor (Cropped) - YouTube [Good Quality] Besides the obvious image size difference, this example is hard to see differences with even after downloading. I think I do see some subtle ringing artifacts around the text. (In reply to Eamonn Rea from comment #10) > Created attachment 170192 [details] > Region Screenshot - Panel [Poor Quality] (In reply to Eamonn Rea from comment #11) > Created attachment 170193 [details] > Current Monitor (Cropped) - Panel [Good Quality] I can see that the second image is larger and has some ringing artifacts. The ringing artifacts seem to be from the Lanczos scaling algorithm used when fractional scaling is used. When screen images are scaled back down to their original size, that should be pretty much dealt with. I could try a bicubic (often just called cubic) or bilinear (often just called linear) scaling algorithm instead. Lanczos is the fanciest algorithm available in OpenCV, but can cause ringing artifacts where abrupt color changes occur. Bicubic and Bilinear might be blurrier than Lanczos. Bilinear might have problems when scaling beyond 2x, but might be better than bicubic at scales below that. If you're interested in these kinds of things, check out this gallery: https://en.wikipedia.org/wiki/Comparison_gallery_of_image_scaling_algorithms Unfortunately, it doesn't have an example of the Lanczos algorithm.
Git commit 64d1a295e6868e5a6762362249dd792bd210162f by Noah Davis. Committed on 07/06/2024 at 10:25. Pushed by ndavis into branch 'master'. ExportManager: Scale back to original scale if possible when writing an image This way when you have a 1920x1080@1x screen and a 3840x2160@2x screen, a rectangular screenshot on the 1080p screen gives a 1x scale image instead of a 2x scale image when the image is finally saved. M +30 -2 src/ExportManager.cpp https://invent.kde.org/graphics/spectacle/-/commit/64d1a295e6868e5a6762362249dd792bd210162f
By the title of it "scale back" I understand that some back and forth with scaling is being performed. Is this necessary even when capturing content the falls entirely within one screen? Isn't it possible to detect that the content falls within the screen boundaries, and then just capture according to the characteristics of that screen, without the need for further re-scaling? (I have no idea about how any of this works, but it just seems strange to me having to do some manipulation on the image, when the content the user wants to capture has a fully predictable and single scaling/resolution, not a mix and match scenario) Thanks
(In reply to Andrea Ippolito from comment #15) > By the title of it "scale back" I understand that some back and forth with > scaling is being performed. > > Is this necessary even when capturing content the falls entirely within one > screen? > > Isn't it possible to detect that the content falls within the screen > boundaries, and then just capture according to the characteristics of that > screen, without the need for further re-scaling? > > (I have no idea about how any of this works, but it just seems strange to me > having to do some manipulation on the image, when the content the user wants > to capture has a fully predictable and single scaling/resolution, not a mix > and match scenario) > > Thanks Here is how a rectangle screenshot works: - Capture a screenshot of all screens. - Have the user select the region they want. It's basically just a crop of an All Screens screenshot. We *could* have you select a portion of the screen and *then* capture a snapshot of just that region, which would allow us to avoid scaling up and down. However, that would make capturing exactly what you want more difficult. The screen content could change while you are making your selection and then you'd have to exit Spectacle and recreate the conditions you were trying to capture. It would also become impossible to capture menus (Qt Widgets, GTK) in a region screenshot unless they were drawn inside of a window, like Qt Quick Menus. The way things currently are, you can take your time deciding which region to select, draw annotations and even undo/redo the region selection in Spectacle's viewer window. If you use the crop tool in the viewer window, you will get exactly the same result as using the region capture window since they're both doing undoable crop operations.
Thanks for your time explaining this, I really appreciate it! I hadn't thought about those scenarios, it makes a lot of sense now.
It might end up being a lot of work (as based on your description of how it currently works, it may need to be re-implemented), and should probably be a separate issue, but maybe there could be an option to only allow region screenshots on one screen at a time? This could be useful if you want to capture specifics of one screen without the risk of bleeding a few pixels into another screen. I believe macOS limits you to taking a region screenshot on one screen, but macOS also doesn't let you take a screenshot of menus and doesn't pause the display content like Spectacle does. While not pausing the window content could be one solution, having an option to locking region select to one display could be more advantageous. Primarily though, I am thinking it could help to solve our problem here of a region screenshot being a cropped "all screens" screenshot. If we could have an option to limit the region screenshot to one screen (and thus the "dimming" effect would only appear on one screen), we could avoid all of the scaling issues here if my understanding is correct, and thus avoid all of the scaling up and back down. We could capture the display with the "Current Monitor" screenshot and crop that, as that option works perfectly fine in terms of quality and resolution. Again, it's something I'd be happy to file in a separate issue, but I am asking here in case it would be a non-starter. I think the option to restrict region screenshots to a single display is not only a good way to work around this issue and give a better out-of-box behaviour, but has actual tangible benefits for making it easier to take screenshots. Having a way to limit the region screenshot to just one screen would be helpful for increasing precision especially at higher mouse sensitivities.
This appears to be fixed for single-display region screenshots with Spectacle 24.05.2, however I have only tested on a single-scale display. I did some pixel-peeping and the results look virtually identical to my eyes. - I don't have the most fancy colour-measuring equipment or anything but colours also look identical, and I don't see any ringing artifacts. - Everything right down to the number of pixels in the close button for a window is identical in terms of sizing, opacity, colours (measured with KColorChooser) looks identical to me. - File sizes of region screenshots and cropped window screenshots are also pretty much identical. I don't think I mentioned it in this issue but the only remaining problem is that after taking a screenshot, depending on how long it takes the screenshot to save, the enlarged screenshot is briefly overlayed on top of the screen in what can either be a quick flash for a fraction of a second, or a larger length of time if saving a very high resolution image to a slower external drive. I haven't confirmed yet if the issue is fixed on setups with a variety of scale factors but I intend to test that later today when I am on my PC and not my laptop. But overall apart from the above mentioned issue (which I could open a separate ticket about) this issue is entirely resolved for me and I am very pleased. Region screenshots on my laptop at least look, for my purposes and tastes, perfect. My assumption is that region screenshots across displays and so also all-display screenshots will still have the upscaling (so wrong resolution) and ringing artifacts. On my single-display laptop, Entire Desktop screenshots look identical to Current Monitor screenshots and Region Screenshots of the same area. But as far as the exacts of this issue so, I think this is fixed, pending further testing on my desktop with all my displays!
Nevermind, the bug is fixed on my laptop it seems but not on my multi-screen Desktop PC.
After further testing on my PC, my findings are: - Both scaled and non-scaled displays still have the incorrect resolution. - This issue appears fixed on my laptop which has a single display, but my laptop is using a 145% scale factor and a single display, whereas my PC has a 150% display and several 1080p displays with no scaling applied. - Turning off the other displays on my PC will fix the issue and create correct region screenshots the same way my laptop does. - My assumption then is that when I connect my laptop to another display, it will reproduce the bug. - I am taking region screenshots on a multi-screen setup but the region screenshots themselves are confined to a single display. - Despite the resolution being correct on single-display setups (with and without scaling, the invalid scaling is not exclusive to multi-screen setups), the resolution preview box still displays the incorrect resolution. This displayed resolution is correct on multi-scale setups, i.e. a resolution of 3000x2000 on a 1080p display is actually what the screenshot would save as on a multi-screen setup with at least one scaled display, but on a setup with a single scaled display, the displayed resolution is wrong. - Although I note they are exclusive to multi-scale setups, I don't know what would happen if all displays had the same scale factor. Perhaps the issue would be fixed? - The Resolution Preview box bug is probably Bug 483155. I hope this clarifies the state of the bug a little more. Definitely important progress, now Spectacle region screenshots work great on my laptop!
Should be fixed in systemd v256.2 with this cherrypicked commit: https://github.com/systemd/systemd/commit/52371fe5263eb2916dcef69d93515f8d2a8e6043
Oops replied to the wrong issue, sorry...
This is improved but still not entirely fixed in Spectacle 24.08. The resolution issue is fixed on scaled, unscaled, and mixed-scale setups, but the ringing artifacts are still present on mixed-scale setups despite the resolution being correct. These artifacts do not appear to be present when taking a region screenshot of an unscaled display. If I recall, on Spectacle 24.05.2, region screenshots if only one scaled display was connected would save correctly with the correct resolution AND without ringing artifacts. The remaining problem appears to be that ringing artifacts are present when saving a region screenshot of a scaled display with multiple screens using different scaling factors. I believe region screenshots on scaled and unscaled displays are now saving with the correct resolution. The resolution looks correct, when taking a region screenshot that is approximately the size of a 1920x1080 display, the size comes out very close to 1920x1080, so close that you could reasonably put the discrepancy down to inaccuracy on my part. Similarly on a 3840x2160 display, the resolution comes out very close as well. However region screenshots on scaled displays still exhibit the ringing artifacts at least in multi-screen setups, and affects overall image quality even at only slight zoom. These artifacts are not present on unscaled displays, and are not present with single-window screenshots. I will attach a screenshot after posting this reply of the ringing artifacts on a scaled display screenshot. I will attach a screenshot after I submit this comment illustrating the current state of the issue. Note that the screenshot may possibly not contain resolution information as a result of Bug 492226.
Created attachment 172980 [details] Region Screenshot - Example Dot Com [Poor Quality] This is a region screenshot taken from "https://example.com" on a scaled display, taken on a setup which contains one scaled and several unscaled displays. It contains ringing artifacts and is noticeably blurrier than a cropped Current Monitor screenshot.
Created attachment 172981 [details] Current Monitor (Cropped) - Example Dot Com [Good Quality].png This is screenshot of "https://example.com" taken on a scaled display on a setup with one scaled and multiple unscaled displays, with the Current Monitor screenshot option, and cropped down using Gwenview. It is crisp and does not contain ringing artifacts like a Region Screenshot of the same area on the same scaled display would exhibit.
This is still an issue as of Spectacle 24.08.1. The file sizes for region screenshots of windows is also about double that of an equivalent single-window screenshot (for example, taking a region screenshot of most of a maximized window to emulate what a single-window screenshot would do, and taking a single-window screenshot to compare against, both with the same file size and compression levels). Perhaps that is a result of this issue, or needs a separate bug report.