-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
69 lines (65 loc) · 1.87 KB
/
types.ts
File metadata and controls
69 lines (65 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
export enum ImageFormat {
AVIF = 'image/avif',
WEBP = 'image/webp',
JPEG = 'image/jpeg',
PNG = 'image/png'
}
export interface CompressionSettings {
quality: number; // 0.0 to 1.0 for canvas api, usually 0-100 in UI
format: ImageFormat;
scale: number; // 0.1 to 1.0
resizeMode: 'scale' | 'fixed';
width: number;
height: number;
maintainAspectRatio: boolean;
smoothing: number; // 0.0 to 2.0 (pixels radius for blur)
grayscale: boolean;
// Enhancements
sharpen: number; // 0 to 100 (strength)
contrast: number; // 0.5 to 1.5 (1.0 is neutral)
saturation: number; // 0.0 to 2.0 (1.0 is neutral)
// New Advanced
focusBlur: number; // 0 to 50 (strength of peripheral blur)
posterize: number; // 0 to 100 (strength of color reduction)
lossless: boolean; // Use lossless compression (max quality)
}
export interface AnalysisResult {
suggestedQuality: number;
suggestedScale: number;
suggestedSmoothing: number;
suggestedGrayscale: boolean;
suggestedSharpen?: number;
suggestedFocusBlur?: number;
suggestedPosterize?: number;
suggestedContrast?: number;
suggestedSaturation?: number;
reasoning: string;
contentTags: string[];
estimatedReduction: string;
}
export interface FormatComparisonResult {
format: ImageFormat;
size: number;
blob: Blob;
reduction: number;
isBest: boolean;
}
export interface ImageFileState {
id: string; // Unique ID for batch processing
originalFile: File | null;
originalUrl: string | null;
originalSize: number;
originalWidth: number;
originalHeight: number;
compressedUrl: string | null;
compressedSize: number;
compressedBlob: Blob | null;
isCompressing: boolean;
isAnalyzing: boolean;
analysisResult: AnalysisResult | null;
// New
comparisonResults: FormatComparisonResult[];
isComparing: boolean;
// Batch specific status
status: 'pending' | 'processing' | 'done' | 'error';
}