Skip to content

fix(image): auto-detect geometry for v2_eufysecurity event thumbnails#924

Open
ahlers2mi wants to merge 3 commits into
bropat:developfrom
ahlers2mi:claude/busy-fermi-h5f76l
Open

fix(image): auto-detect geometry for v2_eufysecurity event thumbnails#924
ahlers2mi wants to merge 3 commits into
bropat:developfrom
ahlers2mi:claude/busy-fermi-h5f76l

Conversation

@ahlers2mi

@ahlers2mi ahlers2mi commented Jun 18, 2026

Copy link
Copy Markdown

Problem (#890)

Newer firmware (e.g. T8160 / HomeBase T8030, sw 3.4.3.0) delivers event
thumbnails in the v2_eufysecurity:<station_sn>:<id>: format. The
synchronous decodeImage() splices these blobs at a fixed 288x176 4:2:0
geometry. Any image of a different size or chroma-subsampling
(e.g. a 648x488 4:4:4 snapshot) is therefore sheared and
colour-corrupted
.

Because the resulting buffer is not a valid JPEG (it does not start with
FF D8 FF), image-type cannot detect the type either — which is why the
ioBroker eusec adapter ends up writing files with an .undefined
extension (.../last_event/<sn>.undefined) and shows a broken preview.

Fix

Add an async decodeImageAuto() in src/http/utils.ts that:

  • detects v2_eufysecurity: blobs and runs the existing
    decodeV2ImageAuto() (optional jpeg-js dependency), which brute-forces
    the size ladder + chroma-subsampling and re-pins the true width/height,
    reconstructing a correctly proportioned JPEG;
  • falls back to the synchronous decodeImage() when the blob is not a v2
    thumbnail, when jpeg-js is not installed, or when detection fails.

Wired into both image paths:

  • src/http/api.tsgetImage() (HTTP path)
  • src/p2p/session.tsCMD_DATABASE_IMAGE handler (P2P path), now
    resolving the async decode before emitting image download.

With auto-geometry the example T8160 "Hauseingang" thumbnail reconstructs
cleanly at 648x488 / 4:4:4, and image-type correctly reports jpg.

Notes

  • The synchronous decodeImage() is kept as the fallback and remains the
    behaviour when jpeg-js is absent.
  • jpeg-js is already declared in optionalDependencies.
  • Type-checked clean (the two pre-existing src/index.ts isolatedModules
    errors are unrelated to this change).

🤖 Generated with Claude Code


Generated by Claude Code

max246 and others added 3 commits June 8, 2026 08:14
The synchronous decodeImage() splices v2_eufysecurity: thumbnails at a
fixed 288x176 4:2:0 geometry, which shears and colour-corrupts images of
other sizes/subsamplings (e.g. 648x488 4:4:4 snapshots). Because the
resulting buffer is not a valid JPEG, image-type also fails to detect the
type, producing an .undefined file extension (see issue bropat#890).

Add an async decodeImageAuto() that runs decodeV2ImageAuto() (optional
jpeg-js dependency) to recover the true width/height/chroma-subsampling
and reconstruct a correctly proportioned JPEG, falling back to the
synchronous path when the blob is not a v2 thumbnail, jpeg-js is missing,
or detection fails. Wire it into the HTTP getImage path (api.ts) and the
P2P CMD_DATABASE_IMAGE path (session.ts).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KuABAwcNZHmBXNJRQCHTLg
Add unit tests for the v2_eufysecurity image path:
- buildJpegPrefix patches width/height/chroma-subsampling
- spliceV2Image splices the plaintext tail / rejects non-v2 buffers
- decodeImageAuto passes non-v2 buffers through unchanged
- decodeImageAuto falls back to the synchronous splice when jpeg-js
  cannot validate any geometry (never throws)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KuABAwcNZHmBXNJRQCHTLg
@ahlers2mi ahlers2mi changed the title Claude/busy fermi h5f76l fix(image): auto-detect geometry for v2_eufysecurity event thumbnails Jun 18, 2026
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