Image downscaling

Talk about code development, features, specific bugs, enhancements, patches, and similar things.
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.
User avatar
__NM64__
Lunatic
Lunatic
Posts: 359
Joined: 2013-10-17, 05:29
Location: Northeast Ohio

Re: Image downscaling

Unread post by __NM64__ » 2017-06-12, 01:42

petrus wrote:To not open a new thread, is there a config line which disables all interpolation to get crisp images at all sizes?
Kind of late on this, but you may be looking for the setting "image.high_quality_downscaling.min_factor".

Depending on what it is you're looking to achieve, you'll want to set that to either a value of "-1" or "1".

petrus

Re: Image downscaling

Unread post by petrus » 2017-06-16, 20:26

Are you sure? Doesn't seem to work, just tried both values with restarts, yet images remain interpolated.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35475
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Image downscaling

Unread post by Moonchild » 2017-06-17, 12:54

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.
"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

petrus

Re: Image downscaling

Unread post by petrus » 2017-06-17, 14:31

I'm a retro gamer who likes his pixels cutting edge! :)

User avatar
__NM64__
Lunatic
Lunatic
Posts: 359
Joined: 2013-10-17, 05:29
Location: Northeast Ohio

Re: Image downscaling

Unread post by __NM64__ » 2017-06-17, 20:15

Moonchild wrote:Pixel-resizing is never used unless forced, because it is a bad scaling method for just about all web content.
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.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35475
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Image downscaling

Unread post by Moonchild » 2017-06-18, 00:50

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

User avatar
__NM64__
Lunatic
Lunatic
Posts: 359
Joined: 2013-10-17, 05:29
Location: Northeast Ohio

Re: Image downscaling

Unread post by __NM64__ » 2017-06-18, 00:55

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.
Oh, right - for downscaling it's really quite illogical even for 8bit NES game sprites.

...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.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35475
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Image downscaling

Unread post by Moonchild » 2017-06-18, 01:00

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

User avatar
__NM64__
Lunatic
Lunatic
Posts: 359
Joined: 2013-10-17, 05:29
Location: Northeast Ohio

Re: Image downscaling

Unread post by __NM64__ » 2017-06-18, 01:32

Moonchild wrote:Not just the performance hit, but also the required buffer to hold that 700% upscaled image.
Would it still be a bad performance hit if it first upscaled to something like 105% and *then* downscaled it to 35%?

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35475
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Image downscaling

Unread post by Moonchild » 2017-06-18, 07:46

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%?
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.
"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

petrus

Re: Image downscaling

Unread post by petrus » 2017-06-21, 15:26

Shouldn't there be a native option to disable filtering still?

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35475
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Image downscaling

Unread post by Moonchild » 2017-06-21, 16:23

petrus wrote:Shouldn't there be a native option to disable filtering still?
No. Why do you think it's needed? Pale Moon is a web browser, not an image manipulation program. its available native features should reflect that and reflect the most common case for 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

petrus

Re: Image downscaling

Unread post by petrus » 2017-06-21, 16:38

>No. Why do you think it's needed?

There should always be an option to display content 1:1 vanilla, as matter of course.
Interpolated images are a distortion, maybe for there better, but still a distortion!

I personally don't like it because It's like adding compression artifacts to every image. :)
Or maybe i just hang too much around retro sites, where a lot of sprites are posted.

And there's nothing worse than interpolated sprites!

User avatar
__NM64__
Lunatic
Lunatic
Posts: 359
Joined: 2013-10-17, 05:29
Location: Northeast Ohio

Re: Image downscaling

Unread post by __NM64__ » 2017-06-21, 19:52

Wait, so is it in fact not currently possible to use plain old nearest neighbor scaling when using exact-multiple zoom levels like 200%, 300%, etc?

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35475
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Image downscaling

Unread post by Moonchild » 2017-06-21, 20:24

petrus wrote:There should always be an option to display content 1:1 vanilla, as matter of course.
And we do, at 100% zoom. Any zoom factor other than 100% will never be "vanilla" and the browser has to choose a default scaling method that is acceptable for the vast majority of web graphics, which is... *drumroll* using interpolation/sub-pixel averaging. On top, we need to do this fast (and uniformly!), because of zoom animation used on web pages.
Nintendo Maniac 64 wrote:Wait, so is it in fact not currently possible to use plain old nearest neighbor scaling when using exact-multiple zoom levels like 200%, 300%, etc?
It's possible, but not when not specified, because for down-scaling web content, you never want nearest-neighbor by default unless the website specifically asks for it (with css crisp-edges). Swapping scaling method based on zoom level in use is bad, see also, once again: scaling animation.
"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

User avatar
__NM64__
Lunatic
Lunatic
Posts: 359
Joined: 2013-10-17, 05:29
Location: Northeast Ohio

Re: Image downscaling

Unread post by __NM64__ » 2017-06-21, 20:31

Moonchild wrote:for down-scaling web content
I said upscaling since I figure that's what petrus means.

I mean, the only way downscaling via nearest neighbor ever looks good even with NES sprites is if the sprites have been pre-processed with 200%, 300%, etc nearest neighbor.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35475
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Image downscaling

Unread post by Moonchild » 2017-06-21, 20:49

It doesn't matter, the same goes for upscaling (but that's not what this thread was started for)
"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

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35475
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Image downscaling

Unread post by Moonchild » 2017-06-21, 21:09

Here, play with this a little. See what the different options do, and see what in general would look better for inclusion in web pages (note jagged edges and text artifacts)

https://jsfiddle.net/oL9r3sqx/
"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

petrus

Re: Image downscaling

Unread post by petrus » 2017-06-21, 21:14

Moonchild wrote: And we do, at 100% zoom. Any zoom factor other than 100% will never be "vanilla" and the browser has to choose a default scaling method that is acceptable for the vast majority of web graphics, which is... *drumroll* using interpolation/sub-pixel averaging. On top, we need to do this fast (and uniformly!), because of zoom animation used on web pages.
Sorry it was a problem on my end, after setting the Windows dpi to 125%, Pale Moon takes this value as a base.
I fixed it by using layout.css.devPixelsPerPx: -1.0 (default) & 0 = OS dpi, 1.0 = force 100%, 1.25 = force 125 etc

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35475
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Image downscaling

Unread post by Moonchild » 2017-06-21, 21:31

By the way, there is an experimental extension for css called "pixelated" as well, but only Chrome implements that (in favor of crisp-edges which still interpolates on upscaling and in general looks better).

If you really need pixelation, you can also use canvas image manipulation, or simply use a pixel-scaled image. All of that though really falls outside our normal web use.

Potential improvements for Pale Moon would be to (1) drop the -moz prefix (also accept unprefixed) and (2) implement "pixelated" (bug #856337) -- patches welcome for either, but they will require some serious review before accepted.

All of that aside: the default rendering method will NOT be changed.
"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

Locked