The stock footage system required a solution to preserve critical EXIF metadata (e.g., camera model, lens information, resolution) during the conversion of RAW files into preview thumbnails. The challenge was that preview JPGs generated from RAW files lacked essential technical details, preventing accurate display in the stock footage listings.
Issue
When generating thumbnail previews from RAW files (e.g., ARW, CR2), the resulting JPGs contained incomplete EXIF metadata. Critical information such as the camera model (SONY ILCE-7RM5), lens specifications (50mm F1.2 DG DN), and full resolution dimensions (9728x6656) were missing from the preview JPGs, even though they were fully embedded in the original RAW files. This resulted in incomplete technical details in the stock footage UI.
Culprit
The issue stemmed from relying on the generated preview JPGs for metadata extraction, rather than the original RAW files. The workflow used tools like exiftool to create JPGs, but these JPGs only contained a subset of EXIF tags, such as basic orientation and timestamp data. The technical details (sensor specifications, lens models, and full resolution) remained embedded in the RAW format and were not accessible through the preview JPGs.
Solution
To preserve metadata integrity, a two-step system was implemented:
Per-File JSON Metadata Sidecars
- Complete Metadata Extraction: The system extracted all EXIF data from the original RAW files during thumbnail generation using
exiftool. - JSON Storage: Metadata was stored in per-file JSON sidecars (
{id}.json), placed alongside the thumbnails in a structured directory. Each JSON file contained comprehensive technical details such as:- Camera model and lens information.
- Full resolution dimensions and megapixel count.
- Sensor specifications and capture mode (e.g., quad-bayer vs. binned resolution).
Sensor Database Integration
A sensor database was created to map camera models to their respective specifications (e.g., sensor type, size, effective megapixels). This database enhanced metadata accuracy and ensured consistency across different camera models.
Quad-Bayer Detection Logic
The system automatically detected capture modes, such as quad-bayer sensors, to determine whether the full pixel-shifted resolution or binned resolution was used. This detection ensured accurate metadata representation for advanced camera features.
Astro Integration
The stock footage page (stock.astro) was modified to read JSON metadata files at build time, merging them with thumbnail data to display complete technical information in the UI. This approach ensured that the frontend received the full set of metadata without relying on the limited preview JPGs.
Watermark Implementation
ImageMagick was used to apply professional watermarks to thumbnails, ensuring branding consistency while preserving metadata integrity. The watermarking process included:
- Semi-transparent text overlays.
- Dynamic rotation and tiling for aesthetic appeal.
Dependency Management
The solution minimized dependencies by replacing tools like jq and bc with portable alternatives (e.g., awk for mathematical operations and inline Python for JSON parsing). This ensured cross-platform compatibility and reduced complexity.
This approach ensured complete metadata preservation, scalable metadata management, and seamless integration with Astro’s frontend while maintaining design and branding standards.