Image downscaling
Forum rules
Please keep everything here strictly on-topic.
This board is meant for Pale Moon source code development related subjects only like code snippets, patches, specific bugs, git, the repositories, etc.
This is not for tech support! Please do not post tech support questions in the "Development" board!
Please make sure not to use this board for support questions. Please post issues with specific websites, extensions, etc. in the relevant boards for those topics.
Please keep things on-topic as this forum will be used for reference for Pale Moon development. Expect topics that aren't relevant as such to be moved or deleted.
Please keep everything here strictly on-topic.
This board is meant for Pale Moon source code development related subjects only like code snippets, patches, specific bugs, git, the repositories, etc.
This is not for tech support! Please do not post tech support questions in the "Development" board!
Please make sure not to use this board for support questions. Please post issues with specific websites, extensions, etc. in the relevant boards for those topics.
Please keep things on-topic as this forum will be used for reference for Pale Moon development. Expect topics that aren't relevant as such to be moved or deleted.
Re: Image downscaling
Just wondering, isn't this sort of things what GPU excel at. Can Pale Moon use the GPU for scaling?
-
- Pale Moon guru
- Posts: 35640
- Joined: 2011-08-28, 17:27
- Location: Motala, SE
Re: Image downscaling
It does for a few things that require very fast scaling (if available), but using the GPU has a lot of overhead and in the end for image scaling you can get unpredictable results if you use the GPU. It's often more economical and faster to use the CPU in-memory than to create a texture, send it to the GPU, tell the GPU to scale, get it back from the GPU only to send it right back out to it afterwards to composite the page.Instant wrote:Just wondering, isn't this sort of things what GPU excel at. Can Pale Moon use the GPU for scaling?
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
-
- Lunatic
- Posts: 366
- Joined: 2013-10-17, 05:29
- Location: Northeast Ohio
Re: Image downscaling
Apologies for the bump, but I've run into an image that's giving some nearest neighbor-like artifacts when scaled. Before I jump to any conclusions, I'd like to ask for clarification on what Pale Moon does regarding the zooming of images...
From what it sounds like, any zoom level between 33%-100% should be resized with Lanczos (presumably Lanczos3) - is this accurate?
If that's the case, would it not be accurate to say that, if I resize an image via Lanczos3 to, say, 44% in a program like XnView and then zoom the same image in Pale Moon to 44%, the image in Pale Moon and XnView should look identical, correct?
From what it sounds like, any zoom level between 33%-100% should be resized with Lanczos (presumably Lanczos3) - is this accurate?
If that's the case, would it not be accurate to say that, if I resize an image via Lanczos3 to, say, 44% in a program like XnView and then zoom the same image in Pale Moon to 44%, the image in Pale Moon and XnView should look identical, correct?
-
- Pale Moon guru
- Posts: 35640
- Joined: 2011-08-28, 17:27
- Location: Motala, SE
Re: Image downscaling
No, it's not using Lanczos3 because that would be much too slow for on-the-fly resizing. It uses Lanczos2, which uses a smaller box and to keep scaling speedily, at the trade-off of some aliasing artifacts. It's a browser, not an image viewer, so trade-offs must be made for web-embedded scaled images to keep things speedy.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
-
- Lunatic
- Posts: 366
- Joined: 2013-10-17, 05:29
- Location: Northeast Ohio
Re: Image downscaling
That's all you had to say, and is why I asked before I jumped to any conclusion - no need to say anything about it not being an image viewer and such.Moonchild wrote:It uses Lanczos2
So that's all then, no problem here - carry on with your day.
-
- Pale Moon guru
- Posts: 35640
- Joined: 2011-08-28, 17:27
- Location: Motala, SE
Re: Image downscaling
For you maybe, but not for the casual reader who may not know the difference between the two who stumbles across this threadNintendo Maniac 64 wrote:That's all you had to say
Then again, I realize I just repeated myself So.. sorry!
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
-
- Lunatic
- Posts: 366
- Joined: 2013-10-17, 05:29
- Location: Northeast Ohio
Re: Image downscaling
I'm not sure if I should make a new thread, but I figured it was moderately related and I had already recently bumped this thread...
What does Pale Moon do for upscaling? Does it use the same algorithm for all upscaling?
What does Pale Moon do for upscaling? Does it use the same algorithm for all upscaling?
-
- Lunatic
- Posts: 366
- Joined: 2013-10-17, 05:29
- Location: Northeast Ohio
Re: Image downscaling
My last question regarding upscaling never got answered, but I did just find out something interesting...
You know how some large images can give aliasing artifacts when resized to fit the screen due to the use of Lanczos2? Well it turns out that these artifacts don't happen when the image's native resolution is an exact multiple of the downscaled size. Therefore, I did a test and it turns out that if Pale Moon first upscales an image to an exact multiple of the target size and then downscales the image, the resulting quality is much better.
In other words, if the target height is 749px (which is what it is for me), you get a better result taking a 2000px high image, upscaling it to 2247px high, and then downscaling it to 749px high rather than trying to downscale from 2000px directly to 749px.
However, this completely ignores the possibility that doing an upscale followed by a downscale may in fact take more processing time than simply using a higher-quality downscaling algorithm such as Laczos3 or the like.
You know how some large images can give aliasing artifacts when resized to fit the screen due to the use of Lanczos2? Well it turns out that these artifacts don't happen when the image's native resolution is an exact multiple of the downscaled size. Therefore, I did a test and it turns out that if Pale Moon first upscales an image to an exact multiple of the target size and then downscales the image, the resulting quality is much better.
In other words, if the target height is 749px (which is what it is for me), you get a better result taking a 2000px high image, upscaling it to 2247px high, and then downscaling it to 749px high rather than trying to downscale from 2000px directly to 749px.
However, this completely ignores the possibility that doing an upscale followed by a downscale may in fact take more processing time than simply using a higher-quality downscaling algorithm such as Laczos3 or the like.
Re: Image downscaling
To not open a new thread, is there a config line which disables all interpolation to get crisp images at all sizes?
I googled around and it should be image.high_quality_downscaling, but with this disabled they are still blurry.
Unlike when you put into userContent.css: img { image-rendering: -moz-crisp-edges; } which does make them pixel perfect.
I googled around and it should be image.high_quality_downscaling, but with this disabled they are still blurry.
Unlike when you put into userContent.css: img { image-rendering: -moz-crisp-edges; } which does make them pixel perfect.
-
- Lunatic
- Posts: 366
- Joined: 2013-10-17, 05:29
- Location: Northeast Ohio
Re: Image downscaling
Kind of late on this, but you may be looking for the setting "image.high_quality_downscaling.min_factor".petrus wrote:To not open a new thread, is there a config line which disables all interpolation to get crisp images at all sizes?
Depending on what it is you're looking to achieve, you'll want to set that to either a value of "-1" or "1".
Re: Image downscaling
Are you sure? Doesn't seem to work, just tried both values with restarts, yet images remain interpolated.
-
- Pale Moon guru
- Posts: 35640
- Joined: 2011-08-28, 17:27
- Location: Motala, SE
Re: Image downscaling
Disabling HQ image downscaling doesn't remove interpolation, it will just switch to a much faster (lanczos2) algorithm which doesn't work well on very large scale factors.
Pixel-resizing is never used unless forced, because it is a bad scaling method for just about all web content.
Pixel-resizing is never used unless forced, because it is a bad scaling method for just about all web content.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
-
- Lunatic
- Posts: 366
- Joined: 2013-10-17, 05:29
- Location: Northeast Ohio
Re: Image downscaling
Would it not at least make sense for ratios like 200%, 300%, etc? I mean, it's what both Apple and Microsoft do on the OS level when DPI scaling is set to such values.Moonchild wrote:Pixel-resizing is never used unless forced, because it is a bad scaling method for just about all web content.
-
- Pale Moon guru
- Posts: 35640
- Joined: 2011-08-28, 17:27
- Location: Motala, SE
Re: Image downscaling
No, it doesn't make sense on integer scale factors either. Microsoft and Apple might use it on UPscaling, perhaps. But that's not what we're talking about here.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
-
- Lunatic
- Posts: 366
- Joined: 2013-10-17, 05:29
- Location: Northeast Ohio
Re: Image downscaling
Oh, right - for downscaling it's really quite illogical even for 8bit NES game sprites.Moonchild wrote:No, it doesn't make sense on integer scale factors either. Microsoft and Apple might use it on UPscaling, perhaps. But that's not what we're talking about here.
...though technically the best way to handle such sprites if you were downscaling to something like 70% would be to do 700% nearest neighbor upscaling and then downscale *that* to the original 70% (which would really be 10% after the upsample) using your typical image downscaling algorithm, but presumably the performance hit from doing all that would presumably be too great.
-
- Pale Moon guru
- Posts: 35640
- Joined: 2011-08-28, 17:27
- Location: Motala, SE
Re: Image downscaling
Not just the performance hit, but also the required buffer to hold that 700% upscaled image.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
-
- Lunatic
- Posts: 366
- Joined: 2013-10-17, 05:29
- Location: Northeast Ohio
Re: Image downscaling
Would it still be a bad performance hit if it first upscaled to something like 105% and *then* downscaled it to 35%?Moonchild wrote:Not just the performance hit, but also the required buffer to hold that 700% upscaled image.
-
- Pale Moon guru
- Posts: 35640
- Joined: 2011-08-28, 17:27
- Location: Motala, SE
Re: Image downscaling
That's not going to help your end result. All these scaling hoops to jump through are simply not going to be efficient and look well at the same time.Nintendo Maniac 64 wrote:Would it still be a bad performance hit if it first upscaled to something like 105% and *then* downscaled it to 35%?
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite