fix(image): auto-detect geometry for v2_eufysecurity event thumbnails#924
Open
ahlers2mi wants to merge 3 commits into
Open
fix(image): auto-detect geometry for v2_eufysecurity event thumbnails#924ahlers2mi wants to merge 3 commits into
ahlers2mi wants to merge 3 commits into
Conversation
Develop > Master sync
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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. Thesynchronous
decodeImage()splices these blobs at a fixed 288x176 4:2:0geometry. 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-typecannot detect the type either — which is why theioBroker
eusecadapter ends up writing files with an.undefinedextension (
.../last_event/<sn>.undefined) and shows a broken preview.Fix
Add an async
decodeImageAuto()insrc/http/utils.tsthat:v2_eufysecurity:blobs and runs the existingdecodeV2ImageAuto()(optionaljpeg-jsdependency), which brute-forcesthe size ladder + chroma-subsampling and re-pins the true width/height,
reconstructing a correctly proportioned JPEG;
decodeImage()when the blob is not a v2thumbnail, when
jpeg-jsis not installed, or when detection fails.Wired into both image paths:
src/http/api.ts—getImage()(HTTP path)src/p2p/session.ts—CMD_DATABASE_IMAGEhandler (P2P path), nowresolving the async decode before emitting
image download.With auto-geometry the example T8160 "Hauseingang" thumbnail reconstructs
cleanly at 648x488 / 4:4:4, and
image-typecorrectly reportsjpg.Notes
decodeImage()is kept as the fallback and remains thebehaviour when
jpeg-jsis absent.jpeg-jsis already declared inoptionalDependencies.src/index.tsisolatedModuleserrors are unrelated to this change).
🤖 Generated with Claude Code
Generated by Claude Code