Skip to content

feat: add extended animation encoding options#5

Open
heidi-alps wants to merge 11 commits into
nieyuyao:mainfrom
heidi-alps:feat/extended-animation-options
Open

feat: add extended animation encoding options#5
heidi-alps wants to merge 11 commits into
nieyuyao:mainfrom
heidi-alps:feat/extended-animation-options

Conversation

@heidi-alps

Copy link
Copy Markdown

Summary

  • Add support for additional WebP animation encoding options (minimize_size, allow_mixed, loop_count, bgcolor, kmin/kmax)
  • Add per-frame encoding configuration (lossless/quality per frame)
  • Fix memory leaks in original encodeAnimation() function

Changes

New Animation Options

Option Type Description
minimize_size boolean Minimize output size (slower, like img2webp -min_size)
allow_mixed boolean Allow mixed lossy/lossless per frame
loop_count number Animation loop count (0 = infinite)
bgcolor number Background color (ARGB format)
kmin / kmax number Keyframe distance control

Per-Frame Configuration

Each frame can now have its own config with lossless and quality settings.

Usage Example

// Basic usage (backward compatible)
const webp = await encodeAnimation(100, 100, true, frames);

// With new options
const webp = await encodeAnimation(100, 100, true, frames, {
  minimize_size: true,
  allow_mixed: true,
  loop_count: 0,
});

// Per-frame settings
const framesWithConfig = [
  { data: frame1, duration: 100, config: { lossless: 1 } },
  { data: frame2, duration: 100, config: { lossless: 0, quality: 80 } },
];

Bug Fixes

  • Added WebPPictureFree() calls to prevent memory leaks
  • Added final NULL frame for correct duration handling
  • Added WebPDataInit/Clear for proper cleanup

Test plan

  • Existing tests pass (npm test)
  • Manual testing with WebP Animator application
  • Verified backward compatibility

🤖 Generated with Claude Code

kakao-heidi-alps and others added 9 commits December 21, 2025 20:16
Add support for additional WebP animation encoding options:
- minimize_size: minimize output size (slower, like img2webp -min_size)
- allow_mixed: allow mixed lossy/lossless per frame
- loop_count: animation loop count (0 = infinite)
- bgcolor: background color (ARGB format)
- kmin/kmax: keyframe distance control

Also add per-frame encoding configuration:
- Each frame can have its own lossless/quality settings
- Enables fine-grained control over animation compression

The existing encodeAnimation() API remains backward compatible.
When options parameter is provided, the new encodeAnimationEx()
C++ function is called internally.

Fixed memory leaks in original encodeAnimation():
- Added WebPPictureFree() calls
- Added final NULL frame for correct duration
- Added WebPDataInit/Clear for proper cleanup

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- libwebp 소스를 직접 포함 (서브모듈 → vendor)
- emsdk 서브모듈 제거 (CI/CD 환경 변수로 대체)
- Makefile/build.sh에서 EMSDK 환경변수 사용
- README.md에 빌드 환경 및 Integration Guide 문서화
- .gitignore에 libwebp 빌드 아티팩트 제외 추가

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Internal GitHub Enterprise restricts workflow files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- libwebp v1.3.2 from https://chromium.googlesource.com/webm/libwebp
- Update README with submodule instructions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- emsdk 3.1.74 from https://github.com/emscripten-core/emsdk
- build.sh auto-installs emsdk if EMSDK env not set
- Makefile uses EMSDK env or falls back to ./emsdk
- Update README with submodule documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add src/webp-wasm.js and src/webp-wasm.wasm to .gitignore
- Remove from git tracking (files generated by npm run build-wasm:dev)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove libwebp entries (managed as submodule)
- Simplify comment

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@nieyuyao

nieyuyao commented Jan 8, 2026

Copy link
Copy Markdown
Owner

Could you add one API example to README?
Additionally, please revert the ci files and then push commits to trigger pipeline.

heidi-alps and others added 2 commits January 10, 2026 20:32
- Add WebPAnimationOptions documentation with all properties
- Add WebPFrameConfig documentation for per-frame settings
- Add example for global animation options (loop_count, bgcolor, etc.)
- Add example for per-frame quality configuration
- Fix typo: "chanel" -> "channel"

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@heidi-alps

Copy link
Copy Markdown
Author

Hi @nieyuyao,

I've addressed your feedback:

  1. README updated - Added API examples for WebPAnimationOptions and WebPFrameConfig:

    • Example with global animation options (loop_count, bgcolor, minimize_size, etc.)
    • Example with per-frame quality configuration
  2. CI files restored - Reverted the commit that removed workflow files.

The CI workflow has been triggered but requires your approval to run (since this is a fork PR).

Could you please approve the workflow run? Thank you!

Comment thread .gitmodules Outdated
@@ -1,10 +1,6 @@
[submodule "libwebp"]
path = libwebp
branch = "v1.3.2"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be better to specify a branch or tag here. @heidi-alps

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

Successfully merging this pull request may close these issues.

3 participants