Skip to content

Commit

Permalink
Change MSRV to 1.65
Browse files Browse the repository at this point in the history
  • Loading branch information
AldaronLau committed Apr 4, 2024
1 parent ec170d1 commit edd2c62
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 51 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
tc: [stable, beta, nightly]
tc: [1.65.0, stable, beta, nightly]
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
Expand All @@ -26,7 +26,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
tc: [stable, beta, nightly]
tc: [1.65.0, stable, beta, nightly]
cc:
- aarch64-linux-android
- i686-pc-windows-gnu
Expand All @@ -53,7 +53,7 @@ jobs:
strategy:
matrix:
os: [macos-latest]
tc: [stable, beta, nightly]
tc: [1.65.0, stable, beta, nightly]
cc: [aarch64-apple-ios]
steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "png_pong"
version = "0.9.0"
version = "0.9.1"
license = "Apache-2.0 OR Zlib"
description = "A pure Rust PNG/APNG encoder & decoder"
repository = "https://github.com/AldaronLau/png_pong"
Expand All @@ -18,7 +18,7 @@ categories = ["multimedia::encoding", "multimedia::images"]
keywords = ["png", "encoder", "decoder", "apng", "image"]
readme = "README.md"
edition = "2021"
rust-version = "1.77"
rust-version = "1.65"

[dependencies.pix]
version = "0.13"
Expand Down
118 changes: 72 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ![PNG Pong](https://raw.githubusercontent.com/AldaronLau/png_pong/master/res/icon.png)
# ![PNG Pong]

#### A pure Rust PNG/APNG encoder & decoder

Expand All @@ -11,27 +11,27 @@ lodepng. This crate allows easy reading and writing of PNG files without any
system dependencies.

### Why another PNG crate?

These are the 4 Rust PNG encoder/decoder crates I know of:
- [png](https://crates.io/crates/png) - The one everyone uses (used to be able
to load less pngs than png_pong and slower, but has caught up).
- [lodepng](https://crates.io/crates/lodepng) - Loads all the PNGs, code
is ported from C, therefore code is hard read & maintain, also uses
slow implementation of deflate/inflate algorithm.
- [imagefmt](https://crates.io/crates/imagefmt) - Abandoned, and
limited in what files it can open, but with a lot less lines of code.
- [imagine](https://crates.io/crates/imagine) - PNG decoding only.

Originally I made the [aci_png](https://crates.io/crates/aci_png) based
on imagefmt, and intended to add more features. At the time, I didn't want to
write a PNG encoder/decoder from scratch so I decided to take `lodepng` which
has more features (and more low level features) and clean up the code, upgrade
to 2018 edition of Rust, depend on the miniz\_oxide crate (because it can
decompress faster than lodepng's INFLATE implementation) and get rid of the libc
dependency so it *actually* becomes pure Rust (lodepng claims to be, but calls
C's malloc and free). Then, I rewrote the entire library, based on
[gift](https://crates.io/crates/gift) and [pix](https://crates.io/crates/pix).
- [png] - The one everyone uses (used to be able to load less pngs than
png\_pong and slower, but has caught up).
- [lodepng] - Loads all the PNGs, code is ported from C, therefore code is hard
read & maintain, also uses slow implementation of deflate/inflate algorithm.
- [imagefmt] - Abandoned, and limited in what files it can open, but with a lot
less lines of code.
- [imagine] - PNG decoding only.

Originally I made the [aci\_png] based on imagefmt, and intended to add more
features. At the time, I didn't want to write a PNG encoder/decoder from
scratch so I decided to take `lodepng` which has more features (and more low
level features) and clean up the code, upgrade to 2018 edition of Rust, depend
on the miniz\_oxide crate (because it can decompress faster than lodepng's
INFLATE implementation) and get rid of the libc dependency so it *actually*
becomes pure Rust (lodepng claims to be, but calls C's malloc and free). Then,
I rewrote the entire library, based on [gift] and [pix].

### Goals

- Forbid unsafe.
- APNG support as iterator.
- Fast.
Expand All @@ -40,19 +40,18 @@ C's malloc and free). Then, I rewrote the entire library, based on
- Save crushed PNG files.
- Clean, well-documented, concise code.
- Implement all completed, non-deprecated chunks in the
[PNG 1.2 Specification](http://www.libpng.org/pub/png/spec/1.2/PNG-Contents.html),
including the
[PNG 1.2 Extensions](https://pmt.sourceforge.io/specs/pngext-1.2.0-pdg-h20.html)
and the
[APNG Specification](https://wiki.mozilla.org/APNG_Specification)
[PNG 1.2 Specification], including the [PNG 1.2 Extensions] and the
[APNG Specification]

### TODO

- Implement APNG reading.
- Implement Chunk reading (with all the different chunk structs).
- StepDecoder should wrap StepDecoder, RasterEncoder should wrap ChunkEncoder
- More test cases to test against.

### Benchmarks And Comparisons

Using Rust 1.52.1, criterion and 4 different PNG sizes with PNGs from
"./tests/png/" (units are: us / microseconds). I stopped anything that was
predicted to take longer than a half hour with criterion with the message
Expand All @@ -68,6 +67,7 @@ predicted to take longer than a half hour with criterion with the message
- sRGBA 4096x4096: Uses `tests/png/noise.png`

#### Encoder

| Library | sRGB 1x1 | sRGBA 1x1 | sRGB 64x64 | sRGBA 64x64 | sRGB 256x256 | sRGBA 256x256 | sRGB 4096x4096 | sRGBA 4096x4096 |
|------------|----------|-----------|------------|-------------|--------------|---------------|----------------|-----------------|
| png_pong | 41.956 | 8.2661 | 1\_025.7 | 700.80 | 2\_646.1 | 5\_061.5 | 587\_320 | 3\_587\_100 |
Expand All @@ -79,6 +79,7 @@ predicted to take longer than a half hour with criterion with the message
| libpng-sys | 6.8443 | 2.9461 | 1\_613.5 | 769.70 | 2\_261.1 | 4\_745.2 | 520\_770 | 2\_926\_900 |

#### Decoder

| Library | sRGB 1x1 | sRGBA 1x1 | sRGB 64x64 | sRGBA 64x64 | sRGB 256x256 | sRGBA 256x256 | sRGB 4096x4096 | sRGBA 4096x4096 |
|------------|----------|-----------|------------|-------------|--------------|---------------|----------------|-----------------|
| png_pong | 7.7520 | 3.9459 | 77.981 | 99.384 | 752.95 | 901.98 | 178\_880 | 570\_200 |
Expand All @@ -90,46 +91,71 @@ predicted to take longer than a half hour with criterion with the message
| libpng-sys | 3.6011 | 0.48747 | 1.8175 | 0.67344 | 25.809 | 4.4175 | 19\_400 | 18\_262 |

## Table of Contents
- [API](#api)
- [Features](#features)
- [Upgrade](#upgrade)
- [License](#license)
- [Contribution](#contribution)

- [API]
- [Features]
- [Upgrade]
- [License]
- [Contribution]

## API
API documentation can be found on [docs.rs](https://docs.rs/png_pong).

API documentation can be found on [docs.rs].

## Features

There are no optional features.

## Upgrade
You can use the
[changelog](https://github.com/AldaronLau/png_pong/blob/master/CHANGELOG.md)
to facilitate upgrading this crate as a dependency.

## MSRV Policy
The current MSRV policy only supports the most recent Rust. This will be
changed in the future.
You can use the [changelog] to facilitate upgrading this crate as a dependency.

## MSRV

The current MSRV is Rust 1.65.

MSRV is updated according to the [Ardaku MSRV guidelines].

## License

Copyright © 2019-2024 The PNG Pong Crate Contributor(s)

Licensed under either of
- Apache License, Version 2.0,
([LICENSE-APACHE](https://github.com/AldaronLau/png_pong/blob/master/LICENSE-APACHE)
or https://www.apache.org/licenses/LICENSE-2.0)
- Zlib License,
([LICENSE-ZLIB](https://github.com/AldaronLau/png_pong/blob/master/LICENSE-ZLIB)
or https://opensource.org/licenses/Zlib)
- Apache License, Version 2.0, ([LICENSE-APACHE] or
<https://www.apache.org/licenses/LICENSE-2.0>)
- Zlib License, ([LICENSE-ZLIB] or <https://opensource.org/licenses/Zlib>)

at your option.

### Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.

Before contributing, check out the
[contribution guidelines](https://github.com/AldaronLau/png_pong/blob/master/CONTRIBUTING.md),
and, as always, make sure to always follow the
[code of conduct](https://github.com/AldaronLau/png_pong/blob/master/CODE_OF_CONDUCT.md).
Before contributing, check out the [contribution guidelines], and, as always,
make sure to always follow the [code of conduct].

[Ardaku MSRV guidelines]: https://github.com/ardaku/.github/blob/v1/profile/MSRV.md
[PNG Pong]: https://raw.githubusercontent.com/AldaronLau/png_pong/v0/res/icon.png
[code of conduct]: https://github.com/AldaronLau/png_pong/blob/v0/CODE_OF_CONDUCT.md
[contribution guidelines]: https://github.com/AldaronLau/png_pong/blob/v0/CONTRIBUTING.md
[LICENSE-APACHE]: https://github.com/AldaronLau/png_pong/blob/v0/LICENSE-APACHE
[LICENSE-ZLIB]: https://github.com/AldaronLau/png_pong/blob/v0/LICENSE-ZLIB
[changelog]: https://github.com/AldaronLau/png_pong/blob/v0/CHANGELOG.md
[docs.rs]: https://docs.rs/png_pong
[API]: #api
[Features]: #features
[Upgrade]: #upgrade
[License]: #license
[Contribution]: #contribution
[PNG 1.2 Specification]: http://www.libpng.org/pub/png/spec/1.2/PNG-Contents.html
[PNG 1.2 Extensions]: https://pmt.sourceforge.io/specs/pngext-1.2.0-pdg-h20.html
[APNG Specification]: https://wiki.mozilla.org/APNG_Specification
[gift]: https://crates.io/crates/gift
[pix]: https://crates.io/crates/pix
[aci\_png]: https://crates.io/crates/aci_png
[png]: https://crates.io/crates/png
[lodepng]: https://crates.io/crates/lodepng
[imagefmt]: https://crates.io/crates/imagefmt
[imagine]: https://crates.io/crates/imagine

0 comments on commit edd2c62

Please sign in to comment.