Skip to content

Commit d73e89a

Browse files
committed
feat: Implement Phase 5.2 - Advanced WASM features for media processing
- Add comprehensive EXIF data extraction support (camera info, GPS, lens data) - Implement histogram analysis for RGB and luminance channels - Add exposure detection (overexposed/underexposed warnings) - Implement color space detection (sRGB, Adobe RGB, CMYK, grayscale) - Add bit depth detection (8-bit, 16-bit, 32-bit/HDR) - Detect progressive JPEG and interlaced PNG formats - Add animated WebP detection with frame count - Implement JPEG quality estimation - Add memory efficiency tracking with buffer management - Export new types in index.ts (ColorSpace, ExifData, HistogramData) - Add 21 comprehensive tests for advanced WASM features - All 91 media tests passing
1 parent b74d95f commit d73e89a

File tree

5 files changed

+837
-8
lines changed

5 files changed

+837
-8
lines changed

src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,8 @@ export type {
4747
ImageMetadata,
4848
MediaOptions,
4949
InitializeOptions,
50-
ImageFormat
50+
ImageFormat,
51+
ColorSpace,
52+
ExifData,
53+
HistogramData
5154
} from './media/types.js';

src/media/types.ts

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,63 @@
33
*/
44
export type ImageFormat = 'jpeg' | 'png' | 'webp' | 'gif' | 'bmp' | 'unknown';
55

6+
/**
7+
* Color space types
8+
*/
9+
export type ColorSpace = 'srgb' | 'adobergb' | 'rgb' | 'cmyk' | 'gray' | 'lab' | 'xyz';
10+
11+
/**
12+
* EXIF data structure
13+
*/
14+
export interface ExifData {
15+
/** Camera manufacturer */
16+
make?: string;
17+
/** Camera model */
18+
model?: string;
19+
/** Image orientation (1-8) */
20+
orientation?: number;
21+
/** Date and time of original capture */
22+
dateTime?: string;
23+
/** Exposure time in seconds */
24+
exposureTime?: number;
25+
/** F-number (aperture) */
26+
fNumber?: number;
27+
/** ISO speed rating */
28+
iso?: number;
29+
/** Focal length in mm */
30+
focalLength?: number;
31+
/** Flash fired */
32+
flash?: boolean;
33+
/** Lens model */
34+
lensModel?: string;
35+
/** GPS latitude */
36+
gpsLatitude?: number;
37+
/** GPS longitude */
38+
gpsLongitude?: number;
39+
/** GPS altitude in meters */
40+
gpsAltitude?: number;
41+
/** Copyright information */
42+
copyright?: string;
43+
/** Artist/photographer */
44+
artist?: string;
45+
/** Software used */
46+
software?: string;
47+
}
48+
49+
/**
50+
* Histogram data for image analysis
51+
*/
52+
export interface HistogramData {
53+
/** Red channel histogram (256 values) */
54+
r: Uint32Array;
55+
/** Green channel histogram (256 values) */
56+
g: Uint32Array;
57+
/** Blue channel histogram (256 values) */
58+
b: Uint32Array;
59+
/** Luminance histogram (256 values) */
60+
luminance: Uint32Array;
61+
}
62+
663
/**
764
* Metadata extracted from an image
865
*/
@@ -13,14 +70,36 @@ export interface ImageMetadata {
1370
height: number;
1471
/** Detected image format */
1572
format: ImageFormat;
73+
/** MIME type */
74+
mimeType?: string;
1675
/** Whether the image has an alpha channel (transparency) */
1776
hasAlpha?: boolean;
1877
/** EXIF metadata if available */
19-
exif?: Record<string, any>;
78+
exif?: ExifData;
2079
/** File size in bytes */
2180
size?: number;
2281
/** Source of metadata extraction (for debugging) */
2382
source?: 'wasm' | 'canvas' | 'fallback';
83+
/** Color space of the image */
84+
colorSpace?: ColorSpace;
85+
/** Bit depth per channel */
86+
bitDepth?: number;
87+
/** Whether this is an HDR image */
88+
isHDR?: boolean;
89+
/** Histogram data for exposure analysis */
90+
histogram?: HistogramData;
91+
/** Exposure warning based on histogram analysis */
92+
exposureWarning?: 'overexposed' | 'underexposed' | 'normal';
93+
/** Whether the image uses progressive/interlaced encoding */
94+
isProgressive?: boolean;
95+
/** Whether the image uses interlaced encoding (PNG) */
96+
isInterlaced?: boolean;
97+
/** Whether the image is animated */
98+
isAnimated?: boolean;
99+
/** Number of frames (for animated images) */
100+
frameCount?: number;
101+
/** Estimated JPEG quality (0-100) */
102+
estimatedQuality?: number;
24103
}
25104

26105
/**
@@ -55,4 +134,6 @@ export interface WASMModule {
55134
extractMetadata(data: Uint8Array): ImageMetadata | undefined;
56135
/** Free allocated memory */
57136
cleanup(): void;
137+
/** Get count of allocated buffers (for testing) */
138+
getAllocatedBufferCount?(): number;
58139
}

0 commit comments

Comments
 (0)