feat(image): native format-übergreifende sdata-Metadaten in Bildern (RFC 0005)#76
Merged
Conversation
…(RFC 0005) Neuer Pillow-freier Layer sdata/imagemeta.py bettet sdata-Metadaten nativ in Bild-Bytes ein bzw. liest sie aus — einheitliche API über fünf Container: - PNG -> iTXt-Chunk (Keyword sdata) - JPEG -> APP1-Segment (Kennung sdata\0) - JP2 -> uuid-Box (feste sdata-UUID) vor jp2c - GIF -> Comment-Extension (Praefix sdata\0) - WebP -> eigener RIFF-Chunk sdAT (von Decodern ignoriert) Fassade: detect_format / embed / extract / supported_formats. Replace-Semantik (idempotent), lenient beim Lesen, Registry erweiterbar. Format-Erkennung ueber Magic-Bytes; reiner Standardbibliotheks-Code (struct/zlib). Image nutzt den Layer: save() waehlt den Container an der Endung, bettet ohne Re-Encoding ein wenn der Inhalt schon passt (sonst Pillow-Transkodierung); from_file/from_bytes lesen eingebettete Metadaten Pillow-frei zurueck; neu: Image.embedded_metadata(). imagemeta.py wird gemessen und ist zu 100% durch synthetische Container-Bytes abgedeckt (Pillow-frei); zusaetzliche Pillow-Round-Trips ueber alle fuenf Formate sichern die Decodier-Integritaet. image.py bleibt in der Coverage-omit. RFC 0005 dokumentiert Entwurf und WebP-Entscheidung (sdAT-Chunk statt VP8X+XMP); API-Referenz + mkdocs-Nav ergaenzt.
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Documentation | 14 minor |
| Security | 35 high |
🟢 Metrics 159 complexity · 0 duplication
Metric Results Complexity 159 Duplication 0
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
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.
Was
sdata bekommt eigenen Code, um Metadaten nativ in Bilddateien zu schreiben
und zu lesen — mit einer API über fünf Container. Bisher konnte
Imagedas nurfür PNG (über Pillows
PngInfo).Neuer Layer
sdata/imagemeta.py— reiner Python-Code (Standardbibliothek,keine Pillow-Abhängigkeit):
iTXt-Chunk vorIENDsdataAPP1-Segment hinter SOIsdata\0-Präfixuuid-Box (ISO BMFF) vorjp2csdata\0-PräfixsdATsdATFassade:
detect_format/embed/extract/supported_formats. Format-Erkennungüber Magic-Bytes; Replace-Semantik (idempotent); lenient beim Lesen; Registry
erweiterbar (TIFF/… als zwei Funktionen + Eintrag).
Image-Integration
save()wählt den Container an der Datei-Endung, bettet ohne Re-Encoding ein,wenn der Inhalt schon passt (sonst Pillow-Transkodierung); unbekannte Formate via
Pillow ohne Einbettung (Warnung).
from_file/from_byteslesen eingebettete Metadaten Pillow-frei zurück.Image.embedded_metadata().WebP-Entscheidung
Empirisch behält ein zusätzlicher, unbekannter RIFF-Chunk (
sdAT) die Dekodier-Integrität (libwebp/Pillow ignorieren unbekannte Chunks; Größe/Pixel unverändert) —
robuster und einfacher als VP8X+XMP. Trade-off + Zukunft in RFC 0005 §4/§7.
Tests / CI
tests/test_imagemeta.py: synthetische Container-Bytes →imagemeta.py100 % (Pillow-frei: Replace, fehlende Nutzlast, JPEG-Standalone/Non-FF-Marker,
JP2-XLBox/
LBox==0/malformed-Guard, GIF mit/ohne (Local) Color Table + Nicht-Comment-Extensions, WebP-Padding) + Pillow-Round-Trips über alle fünf Formate.
tests/test_image.py: einheitlicheImage-API über PNG/JPEG/JP2/GIF/WebP + Transkodierung.Kanonische CI: 594 passed, 7 skipped,
imagemeta.py259/259 100 %,TOTAL 100 %,
mkdocs build --strictgrün. (imagemeta.pygemessen;image.pybleibt in
omit.)Kompatibilität
Strikt additiv;
Image-Signaturen unverändert; PNG-Round-Trips kompatibel (jetztiTXtstattPngInfo, gleichessdata-Keyword). RFC 0005 + API-Referenz + Nav ergänzt.