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

Compression filesize changes between v0.17.5 - v0.17.9 #404

Closed
JamesMcGuigan opened this issue Jul 26, 2023 · 1 comment
Closed

Compression filesize changes between v0.17.5 - v0.17.9 #404

JamesMcGuigan opened this issue Jul 26, 2023 · 1 comment

Comments

@JamesMcGuigan
Copy link

Recently run cargo update on my project and noticed differences in png file compression size between png versions v0.17.5-v0.17.9 for an otherwise identically rendered fractal.

I started with png="=0.17.5" in Cargo.toml and ran cargo update; ./fractal.sh. This would update Cargo.lock, perform a clean release build and regenerate the fractal images. This did not result in a git diff.

I incrementally version bumped png from v0.17.5 -> v0.17.9 and observed the following changes in filesize

CHANGE: fractal.png
21189 bytes (=0.17.5)
29596 bytes (=0.17.6) +40%
29596 bytes (=0.17.7) SAME
24981 bytes (=0.17.8) -20%
24981 bytes (=0.17.9) SAME == +20% overall

CHANGE: fractal.zoom.png
38284 bytes (=0.17.5)
50080 bytes (=0.17.6) +30%
50080 bytes (=0.17.7) SAME
45547 bytes (=0.17.8) -10%
45547 bytes (=0.17.9) SAME == +20% overall

Unsure if my fractal images count as a representative image sample, but it appears something in the png compression algorithm was refactored in versions 0.17.6 resulting in 30-40% filesize increase, following a second refactor in 0.17.8 that reduced filesize 10-20%, whilst still remaining 20% larger than 0.17.5

I have documented this testcase as a series of git commits, in this branch:

JamesMcGuigan/fractals@331dd24

fractal.sh | png="=0.17.5" 

JamesMcGuigan/fractals@15f12fb

fractal.sh | png="=0.17.6"
cargo update
    Updating crates.io index
    Updating git repository `[https://github.com/yewstack/yew/`](https://github.com/yewstack/yew/%60)
    Removing adler32 v1.2.0
    Removing deflate v1.0.0
    Updating png v0.17.5 -> v0.17.6

CHANGE: fractal.png      | 21189 -> 29596 bytes (+40%)
CHANGE: fractal.zoom.png | 38284 -> 50080 bytes (+30%)

JamesMcGuigan/fractals@a596fd3

fractal.sh | png="=0.17.7"
cargo update
    Updating crates.io index
    Updating git repository `[https://github.com/yewstack/yew/`](https://github.com/yewstack/yew/%60)
    Updating miniz_oxide v0.5.4 -> v0.6.2
    Updating png v0.17.6 -> v0.17.7

SAME: fractal.png      | 29596 bytes
SAME: fractal.zoom.png | 50080 bytes

JamesMcGuigan/fractals@760699d

fractal.sh | png="=0.17.8"
cargo update
    Updating crates.io index
    Updating git repository `[https://github.com/yewstack/yew/`](https://github.com/yewstack/yew/%60)
      Adding fdeflate v0.3.0
    Removing miniz_oxide v0.6.2
    Updating png v0.17.7 -> v0.17.8

CHANGE: fractal.png      | 21189 -> 29596 -> 24981 bytes (+20% overall)
CHANGE: fractal.zoom.png | 38284 -> 50080 -> 45547 bytes (+20% overall)

JamesMcGuigan/fractals@9070746

fractal.sh | png="=0.17.9"
cargo update
    Updating crates.io index
    Updating git repository `[https://github.com/yewstack/yew/`](https://github.com/yewstack/yew/%60)
    Updating png v0.17.8 -> v0.17.9

SAME: fractal.png      | 24981 bytes
SAME: fractal.zoom.png | 45547 bytes
JamesMcGuigan added a commit to JamesMcGuigan/fractals that referenced this issue Jul 26, 2023
JamesMcGuigan added a commit to JamesMcGuigan/fractals that referenced this issue Jul 26, 2023
@fintelia
Copy link
Contributor

We completely changed the compression libraries in 0.17.6 and again in 0.17.8!

As of 0.17.8, we use an extremely fast approach from fdeflate if you use Compression::Fast (which the image crate uses by default unless you override it) and use flate2 which is much slower but gets better compression ratios otherwise.

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

2 participants