Thank you for your interest in contributing to JuicyPixels-webp!
- Clone the repository
- Install Stack: https://docs.haskellstack.org/
- Build the project:
stack build
- Run tests:
stack test
JuicyPixels-webp/
├── src/ # Source code (40 modules, ~11,273 lines)
│ └── Codec/Picture/
│ ├── WebP.hs # Public API
│ └── WebP/Internal/ # Internal modules
├── test/ # Test suite (27 modules, ~5,244 lines)
├── docs/ # Specification documents
│ ├── webp-format.md # VP8L lossless spec (RFC 9649)
│ ├── vp8-bitstream.md # VP8 lossy spec (RFC 6386)
│ └── libwebp/ # Reference implementation
├── PLAN.md # Original implementation plan
├── STATUS.md # Current implementation status
└── README.md
- Use Ormolu for formatting:
nix fmtorormolu --mode inplace src/ test/ - Follow existing naming conventions
- Add Haddock documentation for public functions
- Use strict evaluation (
!) for performance-critical paths - Prefer explicit type signatures
- Check
STATUS.mdfor current state and future enhancements - Create a branch:
git checkout -b feature/your-feature - Implement with tests
- Ensure all tests pass:
stack test - Update documentation
- Submit a pull request
- Add a failing test that demonstrates the bug
- Fix the bug
- Verify the test now passes
- Update test/TestNotes.md if relevant
- Add benchmarks (see
bench/directory structure below) - Profile with
stack build --profile - Optimize hot paths
- Verify correctness with existing tests
All contributions must:
- ✅ Pass existing tests (
stack test) - ✅ Add tests for new functionality
- ✅ Maintain or improve test coverage
Test guidelines:
- Unit tests for individual functions
- Integration tests for components
- Property tests for algorithmic correctness
- Real image tests when applicable
- Update
README.mdfor API changes - Update
test/TestNotes.mdfor new tests - Update
STATUS.mdfor implementation progress - Add Haddock comments for public APIs
- VP8L transforms — predictor, color, and color-indexing transforms not yet used in encoding (larger files, correct output)
- VP8 coefficient probability updates — encoder uses fixed defaults
- VP8 segmentation — decoder supports it, encoder doesn't use it
- Advanced mode selection — encoder uses simple heuristics
- Benchmark against libwebp
- SIMD acceleration
- Streaming decode for very large images
- Fuzz testing with random/malformed inputs
- Comparison against
dwebpoutput for more image variants
# Development build (faster)
stack build --fast
# Optimized build
stack build
# Run tests
stack test
# Run specific test
stack test --test-arguments "-m BitReader"
# With coverage
stack test --coverage
# Format code
nix fmt
# Or with ormolu directly
ormolu --mode inplace $(find src test -name '*.hs')case decodeWebP bs of
Left err -> putStrLn $ "Detailed error: " ++ err
Right img -> ...import Codec.Picture.WebP.Internal.BitReader
let reader = initBitReader bs
print $ getBytesRemaining readerimport Codec.Picture.WebP.Internal.Container
case parseWebP bs of
Right webpFile -> print webpFile
Left err -> putStrLn errBefore submitting a PR:
- Code compiles without warnings
- All tests pass (
stack test) - New tests added for new functionality
- Code formatted with Ormolu
- Documentation updated
- Commit messages are descriptive
- No unrelated changes included
- Check
STATUS.mdfor current implementation state - Check
test/TestNotes.mdfor test structure - Open an issue for discussions
By contributing, you agree that your contributions will be licensed under the BSD-3-Clause license.