Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(FEATURE SUGGESTION) Disable interlacing if the optimization is inefficient. #667

Open
seacat17 opened this issue Jan 6, 2025 · 23 comments

Comments

@seacat17
Copy link

seacat17 commented Jan 6, 2025

So basically I just closed an issue that had something to do with interlacing. In short: I did not have the "--force" flag that would... Ya know... Force the result to be recorded into the file even if it is bigger than the source, so the source material got recorded into the file instead, confusing me.

I have a weird feature suggestion. Basically, the interlacing does increase the file size for some images, but for some images - it really doesn't. It would be cool to optimize the image with interlacing first and then if it is ineffective - use default optimization and record it into the file instead of the unoptimized material.

This could be done with the (for example) "--interlace effective". In this case if I have a bunch of images in a folder - it would optimize them all and apply interlacing where it is effective only.

@andrews05
Copy link
Collaborator

andrews05 commented Jan 6, 2025

When you say for some images interlacing doesn't increase the file size, do you mean vs the original file or vs optimising without interlacing?
Interlacing is pretty much universally less efficient. Oxipng may be able to achieve a smaller file than the original even with interlacing on, but that will be thanks to other optimisations it performs. Turning interlacing off will almost certainly give an even smaller file.

@TPS
Copy link

TPS commented Jan 6, 2025

@andrews05 This might be another (less-priority) choice to throw into #523, given enough idle cores?

@seacat17
Copy link
Author

seacat17 commented Jan 6, 2025

When you say for some images interlacing doesn't increase the file size, do you mean vs the original file or vs optimising without interlacing?

Vs the original of course. I understand the drawbacks of interlacing but the main benefit of it is just too good for my case.

@andrews05
Copy link
Collaborator

Right, I'm just trying to understand the use case for what you're proposing. If you need interlacing on, then --interlace effective may turn it off for some images. If you don't mind it being off, then leave it off for best compression.
In what scenario would you want to use such an option?

@seacat17
Copy link
Author

seacat17 commented Jan 6, 2025

Right, I'm just trying to understand the use case for what you're proposing. If you need interlacing on, then --interlace effective may turn it off for some images. If you don't mind it being off, then leave it off for best compression.
In what scenario would you want to use such an option?

A webcomic. If the reader has slow connection - it would be a torture to wait until the page loads from top to bottom. Being able to see the scene at least on SOME pages before the entire file is loaded would be cool.

@andrews05
Copy link
Collaborator

Hm, wouldn’t that be oddly inconsistent? Why not turn it on for all images?

@seacat17
Copy link
Author

seacat17 commented Jan 6, 2025

It would be convenient where it is effective. There are still people with limited internet traffic (like me). If it can be displayed instantly with interlacing and with the reduced size - then let's go for it. If it can't - let's just go for reduced file size.

@TPS
Copy link

TPS commented Jan 6, 2025

@seacat17 Not to be completely devil's advocate, but why not use WebP as your (current) primary format?

@seacat17
Copy link
Author

seacat17 commented Jan 6, 2025

@seacat17 Not to be completely devil's advocate, but why not use WebP as your (current) primary format?

It doesn't have interlacing at all 🥹

I really wish JPEG XL wasn't getting purged from the web, I love it but it's incompatible.

@TPS
Copy link

TPS commented Jan 7, 2025

A webcomic. If the reader has slow connection - it would be a torture to wait until the page loads from top to bottom. Being able to see the scene at least on SOME pages before the entire file is loaded would be cool.

@seacat17 A more modern format would obviate the need for hacky interlaced/progressive decoding by having the actual full image quickly load. Right now, WebP & AVIF are the universal modern image formats, & for your use case, WebP is the obvious choice. Why waste time messing around w/ PNG hacking unless you've legacy requirements? Additionally, I've had great results for WebP @ 1% (!) quality, & amazing 1s @ 10%.

I suggest putting time into that than burning 10× CPU cycles optimizing 0.1% bytes from PNG, just to add 10% back via interlacing, or 1st quantize to remove colors if you must have PNG for whatever reason.

I really wish JPEG XL wasn't getting purged from the web, I love it but it's incompatible.

We agree completely on this, hence the "Right now" proviso earlier.

@seacat17
Copy link
Author

seacat17 commented Jan 7, 2025

If my download speed is 10kb/s (that actually happens sometimes) - will WEBP help me?

@TPS
Copy link

TPS commented Jan 8, 2025

@seacat17 Yes, of course, especially as the WebP can be substantially smaller than PNG could be. If you combine via some ingenuity & have, e.g., low-quality WebP thumbnails (where size of WebP [thumbnail + full image] is still much smaller than best PNG size), you'll receive maximum benefits @ much more efficiency.

@andrews05
Copy link
Collaborator

Regardless of WebP, I'm still unsure of the merits of the proposed feature. I don't think comparison vs the original file size is beneficial - it could be bloated for any number of reasons, or be highly optimised beyond what oxipng can do anyway.
I think you would be better off simply forcing interlacing on for all images, then take a look at the results yourself and consider if you would prefer any of them to have interlacing off instead.

@seacat17
Copy link
Author

seacat17 commented Jan 8, 2025

So this feature isn't coming... Do you know any other interlaced image formats that work in the stable build of Firefox?

@andrews05
Copy link
Collaborator

Gif? 😂
JPEG XL is expected to come to Firefox this year. I don't believe there is anything else.

@TPS
Copy link

TPS commented Jan 8, 2025

@seacat17 If you don't mind lossy, progressive JPG @ certain quality settings is the other way to go.

What's your website address to a worst/typical example? Now I'm curious what your actual conditions are.

@seacat17
Copy link
Author

seacat17 commented Jan 8, 2025

@seacat17 If you don't mind lossy, progressive JPG @ certain quality settings is the other way to go.

What's your website address to a worst/typical example? Now I'm curious what your actual conditions are.

This isn't about the website. It's about the user's internet connection.

@TPS
Copy link

TPS commented Jan 8, 2025

This isn't about the website. It's about the user's internet connection.

@seacat17 No, I understand that. I want to simulate those conditions from your site & see if best solutions can be determined.

@seacat17
Copy link
Author

seacat17 commented Jan 8, 2025

@seacat17 No, I understand that. I want to simulate those conditions from your site & see if best solutions can be determined.

http://archiesoniconline.com/?comic=sonic-the-hedgehog-online-251-cover

@TPS
Copy link

TPS commented Jan 9, 2025

http://archiesoniconline.com/?comic=sonic-the-hedgehog-online-251-cover

@seacat17 That won't let me connect under any circumstance. Is there, e.g., a geo-restriction?

It's not just me: https://downforeveryoneorjustme.com/archiesoniconline.com?proto=http

@seacat17
Copy link
Author

seacat17 commented Jan 9, 2025

http://archiesoniconline.com/?comic=sonic-the-hedgehog-online-251-cover

@seacat17 That won't let me connect under any circumstance. Is there, e.g., a geo-restriction?

It's not just me: https://downforeveryoneorjustme.com/archiesoniconline.com?proto=http

W e i r d . . .

I can connect easily.

Try just http://archiesoniconline.com/

EDIT: Seems like a partial outage, I reported it.

@TPS
Copy link

TPS commented Jan 9, 2025

EDIT: Seems like a partial outage, I reported it.

@seacat17 While waiting, are the images on GitHub, or do you have typical/worst examples I can work on?

@seacat17
Copy link
Author

seacat17 commented Jan 9, 2025

The feature isn't coming anyway. I think I'm gonna close it and sort everything manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants