fix: align preprocess_image preflight order with IEP-0004#2
Open
titusz wants to merge 1 commit into
Open
Conversation
Swap trim_border and remove_transparency in preprocess_image so the order matches IEP-0004 (exif_transpose -> remove_transparency -> trim_border -> resize) and iscc-sdk.image_normalize. Running remove_transparency first gives trim_border a deterministic, encoder-independent reference pixel and avoids alpha-edge halos during the subsequent resize. For opaque inputs the resulting tensor is bit-identical; only inputs combining transparency and a uniform border can produce different Semantic-Codes. Pre-1.0 the project allows this kind of change. Refs #1
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.
Closes #1.
Summary
trim_borderandremove_transparencyiniscc_sci/code_semantic_image.py:preprocess_imageso the order isexif_transpose → remove_transparency → trim_border → resize, matching the normative order in IEP-0004 andiscc_sdk.image.image_normalize.trim_bordera deterministic, encoder-independent reference pixel (img.getpixel((0,0))) and prevents bilinear resize from pulling RGB values out from under transparent pixels.demo.gif(the only sample with transparency); all other samples (bmp,jpg,png,psd,tif) produce bit-identical codes before/after.See #1 for full rationale, impact table, and references.
Output-byte impact (verified on
iscc_samples)ISCC:CEAQ2WTPK2QPZTK4ISCC:CEAQ2WTPK2QPZTK4ISCC:CEAQ2WT7K2Q7YTO4ISCC:CEAQ2UTPK2Q7ZTK4ISCC:CEAQYWTPK2Q7ZTK4ISCC:CEAQYWTPK2Q7ZTK4ISCC:CEAQ2WTPK2Q7ZTK4ISCC:CEAQ2WTPK2Q7ZTK4ISCC:CEAQ2WTPK2Q7ZTK4ISCC:CEAQ2WTPK2Q7ZTK4ISCC:CEAQYWTPK2Q7ZTK4ISCC:CEAQYWTPK2Q7ZTK4Pre-1.0 the project explicitly allows incompatible Semantic-Codes between releases, so backward compatibility on the alpha+border subset is not a constraint.
Test plan
uv run pytest tests/— 27 passediscc_samplesimages, before vs. after — onlydemo.gif(palette transparency) changes; opaque inputs are bit-identicaltest_code_image_semantic_256bitandtest_code_image_semantic_embedding_precisionfixtures for the newdemo.gifoutput