1.1 KiB
1.1 KiB
Pure-Go WebP EXIF RIFF Injector
1. Goal
Completely remove file-based IO and the webpmux dependency by weaving the EXIF chunk into the WebP RIFF byte struct physically in memory.
2. Architecture
Instead of using webpmux passing paths around, helper/exif.go will implement InjectExif(webpBytes []byte, packName, publisher string) ([]byte, error).
3. RIFF Parsing Logic
- Validate
RIFFandWEBPsignatures. - Read all chunks to extract Canvas Width/Height (from
VP8X,VP8L, orVP8). - Identify if
VP8Xis missing, and if so, construct it. We must ensure theEXIFbit flag is set. - Construct the custom
EXIFchunk (which holds the exact binary array and JSON metadata we validated via F-BOT_GO earlier). - Append
EXIFto the end of the WebP chunks, update the mainRIFFfile size pointer, and return the aggregated[]byteslice.
4. Main Command Refactor
cmds/media/sticker.go will stop requesting files via ResolveExif(). It will simply pass the raw Webp bytes received from ConvertImageToWebp or ConvertVideoToWebp into InjectExif and instantly upload the resulting byte array.