# Scan Offsets of Scans <img alt="Soos" src="soos.png" align=right>
Progressive JPEG parser for [HTTP/2 parallel progressive streaming](https://blog.cloudflare.com/parallel-streaming-of-progressive-images/) feature.
It scans a JPEG file looking for Start Of Scan markers. Computes optimal offsets for the `cf-priority-change` header to render "DC-only" and "good enough" progressive stages.
### Building and usage
[Install Rust](https://rustup.rs/) 1.48 or later, and run:
```sh
cargo build --release
```
You can also build for WASM with `rustup target add wasm32-unknown-unknown; cargo build --release --target=wasm32-unknown-unknown` or use [wasm-pack](https://lib.rs/crates/wasm-pack).
This tool requires progressive JPEG files, and doesn't do anything for baseline JPEG or other formats.
```sh
./target/release/soos-cf-priority image.jpg
```
This will print to stdout Cloudflare's `cf-priority` (first line) and `cf-priority-change` (second line) headers with breakpoints for the `image.jpg` file, an error to stderr. The image is read from stdin if not path is specified.
The same can be done programmatically by [using this crate as a library](https://docs.rs/cloudflare-soos) and calling `soos::Scans::from_file(jpeg_bytes)?.cf_priority_change_headers()?`.
### Example tools
```sh
cargo run --example cf-priority -- image.jpg
cargo run --example scan -- image.jpg
```
These tools show debug information used to generate the HTTP priority headers.