@umituz/react-native-ai-generation-content 1.17.231 → 1.17.232
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,286 +1,399 @@
|
|
|
1
|
-
# Photo Restoration
|
|
1
|
+
# Photo Restoration Feature
|
|
2
2
|
|
|
3
3
|
Restore and enhance old, blurry, or damaged photos using AI.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 📍 Import Path
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
- Colorize black and white photos
|
|
11
|
-
- Restore facial details and features
|
|
7
|
+
```typescript
|
|
8
|
+
import { usePhotoRestoreFeature } from '@umituz/react-native-ai-generation-content';
|
|
9
|
+
```
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
**Location**: `src/features/photo-restoration/`
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
## 🎯 Feature Purpose
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
npm install @umituz/react-native-ai-generation-content
|
|
19
|
-
```
|
|
15
|
+
Repair and enhance damaged, old, or low-quality photographs using AI. Removes scratches, fixes blur, colorizes black & white photos, and restores facial details.
|
|
20
16
|
|
|
21
|
-
|
|
17
|
+
---
|
|
22
18
|
|
|
23
|
-
|
|
19
|
+
## 📋 Usage Strategy
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
import { usePhotoRestoreFeature } from '@umituz/react-native-ai-generation-content';
|
|
27
|
-
import * as ImagePicker from 'react-native-image-picker';
|
|
28
|
-
|
|
29
|
-
function PhotoRestorationScreen() {
|
|
30
|
-
const [photo, setPhoto] = useState<string | null>(null);
|
|
31
|
-
|
|
32
|
-
const feature = usePhotoRestoreFeature({
|
|
33
|
-
config: {
|
|
34
|
-
restorationType: 'auto', // 'auto', ' scratches', 'blur', 'colorize'
|
|
35
|
-
onProcessingStart: () => console.log('Starting restoration...'),
|
|
36
|
-
onProcessingComplete: (result) => console.log('Complete:', result),
|
|
37
|
-
onError: (error) => console.error('Error:', error),
|
|
38
|
-
},
|
|
39
|
-
onSelectPhoto: async () => {
|
|
40
|
-
const result = await ImagePicker.launchImageLibrary({ mediaType: 'photo' });
|
|
41
|
-
if (result.assets && result.assets[0].uri) {
|
|
42
|
-
const base64 = await convertToBase64(result.assets[0].uri);
|
|
43
|
-
setPhoto(base64);
|
|
44
|
-
return base64;
|
|
45
|
-
}
|
|
46
|
-
return null;
|
|
47
|
-
},
|
|
48
|
-
onSaveResult: async (imageUrl) => {
|
|
49
|
-
await saveToGallery(imageUrl);
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<View>
|
|
55
|
-
<PhotoUploadCard
|
|
56
|
-
image={photo}
|
|
57
|
-
onSelectImage={feature.selectPhoto}
|
|
58
|
-
title="Select Photo to Restore"
|
|
59
|
-
/>
|
|
60
|
-
|
|
61
|
-
<Button
|
|
62
|
-
title="Restore Photo"
|
|
63
|
-
onPress={feature.process}
|
|
64
|
-
disabled={!feature.isReady || feature.state.isProcessing}
|
|
65
|
-
/>
|
|
66
|
-
|
|
67
|
-
{feature.state.isProcessing && (
|
|
68
|
-
<View>
|
|
69
|
-
<Text>Restoring photo...</Text>
|
|
70
|
-
<ProgressBar progress={feature.state.progress} />
|
|
71
|
-
</View>
|
|
72
|
-
)}
|
|
73
|
-
|
|
74
|
-
{feature.state.result && (
|
|
75
|
-
<ResultDisplay
|
|
76
|
-
originalImage={photo}
|
|
77
|
-
resultImage={feature.state.result.imageUrl}
|
|
78
|
-
onSave={() => feature.saveResult()}
|
|
79
|
-
/>
|
|
80
|
-
)}
|
|
81
|
-
</View>
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
```
|
|
21
|
+
### When to Use This Feature
|
|
85
22
|
|
|
86
|
-
|
|
23
|
+
✅ **Use Cases:**
|
|
24
|
+
- Restoring old family photographs
|
|
25
|
+
- Repairing scratched or torn photos
|
|
26
|
+
- Fixing blurry or out-of-focus images
|
|
27
|
+
- Colorizing black and white photos
|
|
28
|
+
- Enhancing vintage photograph quality
|
|
29
|
+
- Preserving historical images
|
|
87
30
|
|
|
88
|
-
|
|
89
|
-
|
|
31
|
+
❌ **When NOT to Use:**
|
|
32
|
+
- Simple brightness/contrast adjustments (use basic image editing)
|
|
33
|
+
- Background removal (use Remove Background feature)
|
|
34
|
+
- Face swapping (use Face Swap feature)
|
|
35
|
+
- artistic style changes (use Style Transfer)
|
|
90
36
|
|
|
91
|
-
|
|
92
|
-
return (
|
|
93
|
-
<AIFeatureScreen
|
|
94
|
-
featureId="photo-restoration"
|
|
95
|
-
userId="user-123"
|
|
96
|
-
/>
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
```
|
|
37
|
+
### Implementation Strategy
|
|
100
38
|
|
|
101
|
-
|
|
39
|
+
1. **Select restoration type** (auto or specific)
|
|
40
|
+
2. **Upload photo** with clear issues visible
|
|
41
|
+
3. **Preview before/after** comparison
|
|
42
|
+
4. **Allow re-processing** with different settings
|
|
43
|
+
5. **Save high-resolution result**
|
|
44
|
+
6. **Provide quality feedback** mechanism
|
|
102
45
|
|
|
103
|
-
|
|
46
|
+
---
|
|
104
47
|
|
|
105
|
-
|
|
106
|
-
interface PhotoRestoreFeatureConfig {
|
|
107
|
-
restorationType?: 'auto' | 'scratches' | 'blur' | 'colorize' | 'all';
|
|
108
|
-
onProcessingStart?: () => void;
|
|
109
|
-
onProcessingComplete?: (result: PhotoRestoreResult) => void;
|
|
110
|
-
onError?: (error: string) => void;
|
|
111
|
-
}
|
|
112
|
-
```
|
|
48
|
+
## ⚠️ Critical Rules (MUST FOLLOW)
|
|
113
49
|
|
|
114
|
-
###
|
|
50
|
+
### 1. Image Requirements
|
|
51
|
+
- **MUST** provide ONE image to restore
|
|
52
|
+
- **MUST** use high-quality scan (min 1024x1024 recommended)
|
|
53
|
+
- **MUST** ensure photo has visible issues to fix
|
|
54
|
+
- **MUST** use supported formats (JPEG, PNG)
|
|
55
|
+
- **MUST NOT** exceed file size limits (20MB max)
|
|
115
56
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
adjustContrast?: boolean; // Improve contrast and brightness
|
|
123
|
-
}
|
|
124
|
-
```
|
|
57
|
+
### 2. Configuration
|
|
58
|
+
- **MUST** provide valid `userId` for tracking
|
|
59
|
+
- **MUST** specify `restorationType` (auto or specific)
|
|
60
|
+
- **MUST** implement `onError` callback
|
|
61
|
+
- **MUST** implement `onSelectPhoto` callback
|
|
62
|
+
- **MUST** handle all restoration states
|
|
125
63
|
|
|
126
|
-
|
|
64
|
+
### 3. State Management
|
|
65
|
+
- **MUST** check `isReady` before enabling restore button
|
|
66
|
+
- **MUST** display progress during restoration
|
|
67
|
+
- **MUST** handle long processing times (show progress)
|
|
68
|
+
- **MUST** display `error` state with clear messages
|
|
69
|
+
- **MUST** implement proper cleanup on unmount
|
|
127
70
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
71
|
+
### 4. Performance
|
|
72
|
+
- **MUST** implement image compression before upload
|
|
73
|
+
- **MUST** show progress indicator for long operations
|
|
74
|
+
- **MUST** cache restored images locally
|
|
75
|
+
- **MUST** allow users to cancel processing
|
|
76
|
+
- **MUST NOT** restore multiple images simultaneously
|
|
133
77
|
|
|
134
|
-
|
|
78
|
+
### 5. User Experience
|
|
79
|
+
- **MUST** provide before/after comparison
|
|
80
|
+
- **MUST** allow re-processing with different settings
|
|
81
|
+
- **MUST** show estimated processing time
|
|
82
|
+
- **MUST** handle restoration failures gracefully
|
|
83
|
+
- **MUST** provide download/share options
|
|
135
84
|
|
|
136
|
-
|
|
85
|
+
---
|
|
137
86
|
|
|
138
|
-
|
|
87
|
+
## 🚫 Prohibitions (MUST AVOID)
|
|
139
88
|
|
|
140
|
-
|
|
141
|
-
const result = await feature.process({
|
|
142
|
-
restorationType: 'auto',
|
|
143
|
-
});
|
|
144
|
-
```
|
|
89
|
+
### Strictly Forbidden
|
|
145
90
|
|
|
146
|
-
|
|
91
|
+
❌ **NEVER** do the following:
|
|
147
92
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
});
|
|
152
|
-
```
|
|
93
|
+
1. **No Missing Images**
|
|
94
|
+
- Always validate image is selected
|
|
95
|
+
- Never call process() without image
|
|
153
96
|
|
|
154
|
-
|
|
97
|
+
2. **No Auto-Processing**
|
|
98
|
+
- Never start restoration without user action
|
|
99
|
+
- Always require explicit "Restore" button press
|
|
100
|
+
- Provide clear preview before processing
|
|
155
101
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
});
|
|
160
|
-
```
|
|
102
|
+
3. **No Hardcoded Credentials**
|
|
103
|
+
- Never store API keys in component files
|
|
104
|
+
- Use environment variables or secure storage
|
|
161
105
|
|
|
162
|
-
|
|
106
|
+
4. **No Unhandled Errors**
|
|
107
|
+
- Never ignore restoration failures
|
|
108
|
+
- Always explain what went wrong
|
|
109
|
+
- Provide retry or alternative options
|
|
163
110
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
```
|
|
111
|
+
5. **No Memory Leaks**
|
|
112
|
+
- Never store large original and restored images simultaneously
|
|
113
|
+
- Clean up temporary images
|
|
114
|
+
- Implement proper image disposal
|
|
169
115
|
|
|
170
|
-
|
|
116
|
+
6. **No Blocking UI**
|
|
117
|
+
- Never block main thread with image processing
|
|
118
|
+
- Always show progress indicator
|
|
119
|
+
- Allow cancellation of long operations
|
|
171
120
|
|
|
172
|
-
|
|
121
|
+
7. **No Loss of Original**
|
|
122
|
+
- Never overwrite original photo
|
|
123
|
+
- Always keep original for comparison
|
|
124
|
+
- Store both versions separately
|
|
173
125
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## 🤖 AI Agent Directions
|
|
129
|
+
|
|
130
|
+
### For AI Code Generation Tools
|
|
131
|
+
|
|
132
|
+
When using this feature with AI code generation tools, follow these guidelines:
|
|
133
|
+
|
|
134
|
+
#### Prompt Template for AI Agents
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
You are implementing a photo restoration feature using @umituz/react-native-ai-generation-content.
|
|
138
|
+
|
|
139
|
+
REQUIREMENTS:
|
|
140
|
+
1. Import from: @umituz/react-native-ai-generation-content
|
|
141
|
+
2. Use the usePhotoRestoreFeature hook
|
|
142
|
+
3. Select restoration type (auto or specific)
|
|
143
|
+
4. Implement photo selection UI
|
|
144
|
+
5. Validate photo before restoration
|
|
145
|
+
6. Show before/after comparison
|
|
146
|
+
7. Handle long processing times with progress
|
|
147
|
+
8. Implement proper error handling
|
|
148
|
+
9. Allow re-processing with different settings
|
|
149
|
+
10. Implement cleanup on unmount
|
|
150
|
+
|
|
151
|
+
CRITICAL RULES:
|
|
152
|
+
- MUST validate photo before calling restore()
|
|
153
|
+
- MUST show before/after comparison
|
|
154
|
+
- MUST never overwrite original photo
|
|
155
|
+
- MUST handle long processing times
|
|
156
|
+
- MUST allow re-processing
|
|
157
|
+
- MUST implement debouncing (300ms)
|
|
158
|
+
|
|
159
|
+
CONFIGURATION:
|
|
160
|
+
- Provide valid userId (string)
|
|
161
|
+
- Set restorationType: 'auto' | 'scratches' | 'blur' | 'colorize' | 'all'
|
|
162
|
+
- Implement onSelectPhoto callback
|
|
163
|
+
- Implement onSaveResult callback
|
|
164
|
+
- Configure callbacks: onProcessingStart, onProcessingComplete, onError
|
|
165
|
+
|
|
166
|
+
RESTORATION OPTIONS:
|
|
167
|
+
- removeScratches: boolean (remove scratches and tears)
|
|
168
|
+
- fixBlur: boolean (fix blurry photos)
|
|
169
|
+
- colorize: boolean (add color to B&W photos)
|
|
170
|
+
- enhanceFaces: boolean (restore facial details)
|
|
171
|
+
- adjustContrast: boolean (improve contrast and brightness)
|
|
172
|
+
|
|
173
|
+
STRICTLY FORBIDDEN:
|
|
174
|
+
- No missing photo validation
|
|
175
|
+
- No auto-processing without user action
|
|
176
|
+
- No hardcoded API keys
|
|
177
|
+
- No unhandled errors
|
|
178
|
+
- No memory leaks
|
|
179
|
+
- No overwriting original photo
|
|
180
|
+
- No blocking UI
|
|
181
|
+
|
|
182
|
+
QUALITY CHECKLIST:
|
|
183
|
+
- [ ] Photo selection implemented
|
|
184
|
+
- [ ] Restoration type selector
|
|
185
|
+
- [ ] Before/after comparison view
|
|
186
|
+
- [ ] Progress indicator for long operations
|
|
187
|
+
- [ ] Error display with retry option
|
|
188
|
+
- [ ] Re-processing with different settings
|
|
189
|
+
- [ ] Download/share functionality
|
|
190
|
+
- [ ] Original photo preserved
|
|
182
191
|
```
|
|
183
192
|
|
|
184
|
-
|
|
193
|
+
#### AI Implementation Checklist
|
|
194
|
+
|
|
195
|
+
Use this checklist when generating code:
|
|
196
|
+
|
|
197
|
+
- [ ] Feature imported from correct path
|
|
198
|
+
- [ ] Photo selection implemented
|
|
199
|
+
- [ ] Restoration type selector added
|
|
200
|
+
- [ ] Validation before restore()
|
|
201
|
+
- [ ] Before/after comparison view
|
|
202
|
+
- [ ] Progress indicator during processing
|
|
203
|
+
- [ ] Error display with user-friendly message
|
|
204
|
+
- [ ] Re-processing option available
|
|
205
|
+
- [ ] Original photo preserved
|
|
206
|
+
- [ ] Download/share buttons
|
|
207
|
+
- [ ] Cleanup on unmount
|
|
208
|
+
- [ ] Image compression configured
|
|
185
209
|
|
|
186
|
-
|
|
210
|
+
---
|
|
187
211
|
|
|
188
|
-
|
|
189
|
-
import { GridSelector } from '@umituz/react-native-ai-generation-content';
|
|
212
|
+
## 🛠️ Configuration Strategy
|
|
190
213
|
|
|
191
|
-
|
|
192
|
-
{ id: 'auto', name: 'Auto', description: 'Automatic detection' },
|
|
193
|
-
{ id: 'scratches', name: 'Scratches', description: 'Remove scratches & tears' },
|
|
194
|
-
{ id: 'blur', name: 'Blur', description: 'Fix blurry photos' },
|
|
195
|
-
{ id: 'colorize', name: 'Colorize', description: 'Add color to B&W photos' },
|
|
196
|
-
];
|
|
214
|
+
### Essential Configuration
|
|
197
215
|
|
|
198
|
-
|
|
199
|
-
|
|
216
|
+
```typescript
|
|
217
|
+
// Required fields
|
|
218
|
+
{
|
|
219
|
+
userId: string
|
|
220
|
+
restorationType: 'auto' | 'scratches' | 'blur' | 'colorize' | 'all'
|
|
221
|
+
onSelectPhoto: () => Promise<string | null>
|
|
222
|
+
}
|
|
200
223
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
/>
|
|
207
|
-
);
|
|
224
|
+
// Optional callbacks
|
|
225
|
+
{
|
|
226
|
+
onProcessingStart?: () => void
|
|
227
|
+
onProcessingComplete?: (result) => void
|
|
228
|
+
onError?: (error: string) => void
|
|
208
229
|
}
|
|
209
230
|
```
|
|
210
231
|
|
|
211
|
-
###
|
|
232
|
+
### Recommended Settings
|
|
212
233
|
|
|
213
|
-
|
|
214
|
-
|
|
234
|
+
1. **Restoration Types**
|
|
235
|
+
- Auto: Let AI detect issues (recommended for most cases)
|
|
236
|
+
- Scratches: Remove scratches, tears, stains
|
|
237
|
+
- Blur: Fix blurry or out-of-focus images
|
|
238
|
+
- Colorize: Add color to black & white photos
|
|
239
|
+
- All: Apply all restoration techniques
|
|
215
240
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
onShare={() => shareImage(feature.state.result.imageUrl)}
|
|
222
|
-
/>
|
|
223
|
-
)}
|
|
224
|
-
```
|
|
241
|
+
2. **Image Quality**
|
|
242
|
+
- Minimum scan: 1024x1024 resolution
|
|
243
|
+
- Recommended: 2048x2048 or higher
|
|
244
|
+
- Format: JPEG or PNG
|
|
245
|
+
- Max size: 20MB
|
|
225
246
|
|
|
226
|
-
|
|
247
|
+
3. **Performance Settings**
|
|
248
|
+
- Compress images before upload
|
|
249
|
+
- Show progress for long operations
|
|
250
|
+
- Implement timeout (120s default)
|
|
251
|
+
- Enable result caching
|
|
227
252
|
|
|
228
|
-
|
|
253
|
+
---
|
|
229
254
|
|
|
230
|
-
|
|
231
|
-
// Restore old family photographs
|
|
232
|
-
const result = await feature.process({
|
|
233
|
-
removeScratches: true,
|
|
234
|
-
fixBlur: true,
|
|
235
|
-
adjustContrast: true,
|
|
236
|
-
});
|
|
237
|
-
```
|
|
255
|
+
## 📊 State Management
|
|
238
256
|
|
|
239
|
-
###
|
|
257
|
+
### Feature States
|
|
240
258
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
colorize: true,
|
|
245
|
-
});
|
|
246
|
-
```
|
|
259
|
+
**isReady**: boolean
|
|
260
|
+
- Photo selected and validated
|
|
261
|
+
- Check before enabling restore button
|
|
247
262
|
|
|
248
|
-
|
|
263
|
+
**isProcessing**: boolean
|
|
264
|
+
- Restoration in progress
|
|
265
|
+
- Show loading/progress indicator
|
|
266
|
+
- Disable restore button
|
|
249
267
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
268
|
+
**progress**: number (0-100)
|
|
269
|
+
- Restoration progress percentage
|
|
270
|
+
- Update progress bar
|
|
271
|
+
|
|
272
|
+
**error**: string | null
|
|
273
|
+
- Error message if restoration failed
|
|
274
|
+
- Display to user with clear message
|
|
256
275
|
|
|
257
|
-
|
|
276
|
+
**result**: {
|
|
277
|
+
imageUrl: string
|
|
278
|
+
originalImageUrl?: string
|
|
279
|
+
restorationType?: string
|
|
280
|
+
metadata?: any
|
|
281
|
+
}
|
|
258
282
|
|
|
259
|
-
|
|
260
|
-
2. **Start with Auto**: Let AI detect issues first
|
|
261
|
-
3. **Multiple Passes**: Some photos may benefit from multiple restoration passes
|
|
262
|
-
4. **Face Focus**: Enable face enhancement for portrait photos
|
|
263
|
-
5. **Color Accuracy**: Colorization works best with clear reference points
|
|
283
|
+
---
|
|
264
284
|
|
|
265
|
-
##
|
|
285
|
+
## 🎨 Best Practices
|
|
266
286
|
|
|
267
|
-
|
|
268
|
-
const { state, process } = usePhotoRestoreFeature({ ...config });
|
|
287
|
+
### Photo Selection
|
|
269
288
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
289
|
+
1. **Scan Quality**
|
|
290
|
+
- Good: High-resolution scan (300 DPI or higher)
|
|
291
|
+
- Bad: Low-quality photo of photo
|
|
292
|
+
|
|
293
|
+
2. **Lighting**
|
|
294
|
+
- Good: Even, well-lit scans
|
|
295
|
+
- Bad: Harsh shadows or glare
|
|
296
|
+
|
|
297
|
+
3. **Damage Assessment**
|
|
298
|
+
- Start with auto mode to detect issues
|
|
299
|
+
- Use specific restoration for targeted fixes
|
|
300
|
+
|
|
301
|
+
4. **Multiple Restorations**
|
|
302
|
+
- Some photos benefit from multiple passes
|
|
303
|
+
- Allow re-processing with different settings
|
|
304
|
+
|
|
305
|
+
### User Experience
|
|
306
|
+
|
|
307
|
+
1. **Before/After Comparison**
|
|
308
|
+
- Show side-by-side comparison
|
|
309
|
+
- Add slider or toggle for easy comparison
|
|
310
|
+
- Zoom capability for detail inspection
|
|
311
|
+
|
|
312
|
+
2. **Progress Feedback**
|
|
313
|
+
- Show estimated time remaining
|
|
314
|
+
- Update progress regularly
|
|
315
|
+
- Allow cancellation
|
|
316
|
+
|
|
317
|
+
3. **Quality Options**
|
|
318
|
+
- Offer multiple restoration types
|
|
319
|
+
- Show examples of each type
|
|
320
|
+
- Recommend best option
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## 🐛 Common Pitfalls
|
|
325
|
+
|
|
326
|
+
### Quality Issues
|
|
327
|
+
|
|
328
|
+
❌ **Problem**: Poor restoration quality
|
|
329
|
+
✅ **Solution**: Use higher resolution scans, try different restoration types
|
|
330
|
+
|
|
331
|
+
### Performance Issues
|
|
332
|
+
|
|
333
|
+
❌ **Problem**: Very slow processing
|
|
334
|
+
✅ **Solution**: Compress images, show progress, allow cancellation
|
|
335
|
+
|
|
336
|
+
### User Confusion
|
|
337
|
+
|
|
338
|
+
❌ **Problem**: Users don't see improvement
|
|
339
|
+
✅ **Solution**: Provide before/after comparison, zoom capability
|
|
340
|
+
|
|
341
|
+
### Memory Issues
|
|
342
|
+
|
|
343
|
+
❌ **Problem**: App crashes with large images
|
|
344
|
+
✅ **Solution**: Compress images, implement streaming, clean up properly
|
|
345
|
+
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
## 📦 Related Components
|
|
349
|
+
|
|
350
|
+
Use these components from the library:
|
|
351
|
+
|
|
352
|
+
- **PhotoUploadCard**: Upload photo interface
|
|
353
|
+
- **ResultDisplay**: Before/after comparison
|
|
354
|
+
- **RestorationTypeSelector**: Choose restoration type
|
|
355
|
+
- **ProgressBar**: Progress display
|
|
356
|
+
- **ImageComparison**: Side-by-side comparison
|
|
357
|
+
|
|
358
|
+
Located at: `src/presentation/components/`
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
|
|
362
|
+
## 🔄 Migration Strategy
|
|
363
|
+
|
|
364
|
+
If migrating from previous implementation:
|
|
365
|
+
|
|
366
|
+
1. **Update imports** to new path
|
|
367
|
+
2. **Add restoration type selector**
|
|
368
|
+
3. **Implement before/after comparison**
|
|
369
|
+
4. **Update state handling** for new structure
|
|
370
|
+
5. **Add re-processing capability**
|
|
371
|
+
6. **Test all restoration types**
|
|
372
|
+
|
|
373
|
+
---
|
|
374
|
+
|
|
375
|
+
## 📚 Additional Resources
|
|
376
|
+
|
|
377
|
+
- Main documentation: `/docs/`
|
|
378
|
+
- API reference: `/docs/api/`
|
|
379
|
+
- Examples: `/docs/examples/basic/photo-restoration/`
|
|
380
|
+
- Architecture: `/ARCHITECTURE.md`
|
|
381
|
+
|
|
382
|
+
---
|
|
383
|
+
|
|
384
|
+
**Last Updated**: 2025-01-08
|
|
385
|
+
**Version**: 2.0.0 (Strategy-based Documentation)
|
|
276
386
|
|
|
277
|
-
|
|
387
|
+
---
|
|
278
388
|
|
|
279
|
-
|
|
280
|
-
- [HD Touch Up](../hd-touch-up) - High-detail enhancements
|
|
281
|
-
- [Colorization](../colorization) - Add color to B&W photos
|
|
282
|
-
- [Face Detection](../../../domains/face-detection) - Face detection API
|
|
389
|
+
## 📝 Changelog
|
|
283
390
|
|
|
284
|
-
|
|
391
|
+
### v2.0.0 - 2025-01-08
|
|
392
|
+
- **BREAKING**: Documentation format changed to strategy-based
|
|
393
|
+
- Removed extensive code examples
|
|
394
|
+
- Added rules, prohibitions, and AI agent directions
|
|
395
|
+
- Focus on best practices and implementation guidance
|
|
396
|
+
- Added before/after comparison guidelines
|
|
285
397
|
|
|
286
|
-
|
|
398
|
+
### v1.0.0 - Initial Release
|
|
399
|
+
- Initial feature documentation
|
|
@@ -1,247 +1,396 @@
|
|
|
1
|
-
# Upscaling
|
|
1
|
+
# Upscaling Feature
|
|
2
2
|
|
|
3
3
|
Increase image resolution while maintaining quality using AI.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 📍 Import Path
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
- Support for various image formats
|
|
7
|
+
```typescript
|
|
8
|
+
import { useUpscaleFeature } from '@umituz/react-native-ai-generation-content';
|
|
9
|
+
```
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
**Location**: `src/features/upscaling/`
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
## 🎯 Feature Purpose
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
npm install @umituz/react-native-ai-generation-content`
|
|
18
|
-
```
|
|
15
|
+
Increase image resolution by 2x or 4x while maintaining and enhancing quality using AI. Removes noise and artifacts during the upscaling process.
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
---
|
|
21
18
|
|
|
22
|
-
|
|
19
|
+
## 📋 Usage Strategy
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
import { useUpscaleFeature } from '@umituz/react-native-ai-generation-content';
|
|
26
|
-
import * as ImagePicker from 'react-native-image-picker';
|
|
27
|
-
|
|
28
|
-
function UpscaleScreen() {
|
|
29
|
-
const [image, setImage] = useState<string | null>(null);
|
|
30
|
-
|
|
31
|
-
const feature = useUpscaleFeature({
|
|
32
|
-
config: {
|
|
33
|
-
defaultScaleFactor: 2,
|
|
34
|
-
onProcessingStart: () => console.log('Starting upscaling...'),
|
|
35
|
-
onProcessingComplete: (result) => console.log('Complete:', result),
|
|
36
|
-
onError: (error) => console.error('Error:', error),
|
|
37
|
-
},
|
|
38
|
-
onSelectImage: async () => {
|
|
39
|
-
const result = await ImagePicker.launchImageLibrary({ mediaType: 'photo' });
|
|
40
|
-
if (result.assets && result.assets[0].uri) {
|
|
41
|
-
const base64 = await convertToBase64(result.assets[0].uri);
|
|
42
|
-
setImage(base64);
|
|
43
|
-
return base64;
|
|
44
|
-
}
|
|
45
|
-
return null;
|
|
46
|
-
},
|
|
47
|
-
onSaveImage: async (imageUrl) => {
|
|
48
|
-
await saveToGallery(imageUrl);
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
return (
|
|
53
|
-
<View>
|
|
54
|
-
<PhotoUploadCard
|
|
55
|
-
image={image}
|
|
56
|
-
onSelectImage={feature.selectImage}
|
|
57
|
-
title="Select Image to Upscale"
|
|
58
|
-
/>
|
|
59
|
-
|
|
60
|
-
<Button
|
|
61
|
-
title="Upscale Image"
|
|
62
|
-
onPress={feature.process}
|
|
63
|
-
disabled={!feature.isReady || feature.state.isProcessing}
|
|
64
|
-
/>
|
|
65
|
-
|
|
66
|
-
{feature.state.isProcessing && (
|
|
67
|
-
<View>
|
|
68
|
-
<Text>Upscaling image...</Text>
|
|
69
|
-
<ProgressBar progress={feature.state.progress} />
|
|
70
|
-
</View>
|
|
71
|
-
)}
|
|
72
|
-
|
|
73
|
-
{feature.state.result && (
|
|
74
|
-
<Image source={{ uri: feature.state.result.imageUrl }} />
|
|
75
|
-
)}
|
|
76
|
-
</View>
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
```
|
|
21
|
+
### When to Use This Feature
|
|
80
22
|
|
|
81
|
-
|
|
23
|
+
✅ **Use Cases:**
|
|
24
|
+
- Enhancing low-resolution photos
|
|
25
|
+
- Preparing images for print
|
|
26
|
+
- Improving image quality for presentations
|
|
27
|
+
- Upscaling for large format displays
|
|
28
|
+
- Increasing resolution for cropping
|
|
29
|
+
- Enhancing old digital photos
|
|
82
30
|
|
|
83
|
-
|
|
84
|
-
|
|
31
|
+
❌ **When NOT to Use:**
|
|
32
|
+
- Simple resizing without quality enhancement (use basic image resizing)
|
|
33
|
+
- Photo restoration with scratches (use Photo Restoration)
|
|
34
|
+
- Image sharpening only (use HD Touch Up)
|
|
35
|
+
- Artistic style changes (use Style Transfer)
|
|
85
36
|
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<AIFeatureScreen
|
|
89
|
-
featureId="upscaling"
|
|
90
|
-
userId="user-123"
|
|
91
|
-
/>
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
```
|
|
37
|
+
### Implementation Strategy
|
|
95
38
|
|
|
96
|
-
|
|
39
|
+
1. **Select image** to upscale
|
|
40
|
+
2. **Choose scale factor** (2x or 4x)
|
|
41
|
+
3. **Select enhancement options** (denoise, enhance)
|
|
42
|
+
4. **Show file size warning** for 4x upscaling
|
|
43
|
+
5. **Display before/after comparison**
|
|
44
|
+
6. **Provide download in multiple formats**
|
|
97
45
|
|
|
98
|
-
|
|
46
|
+
---
|
|
99
47
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
48
|
+
## ⚠️ Critical Rules (MUST FOLLOW)
|
|
49
|
+
|
|
50
|
+
### 1. Image Requirements
|
|
51
|
+
- **MUST** provide ONE image to upscale
|
|
52
|
+
- **MUST** use reasonable resolution (min 256x256)
|
|
53
|
+
- **MUST** consider file size limits (original < 10MB recommended)
|
|
54
|
+
- **MUST** use supported formats (JPEG, PNG, WebP)
|
|
55
|
+
- **MUST NOT** exceed output dimensions limits
|
|
56
|
+
|
|
57
|
+
### 2. Configuration
|
|
58
|
+
- **MUST** provide valid `userId` for tracking
|
|
59
|
+
- **MUST** specify `scaleFactor` (2 or 4)
|
|
60
|
+
- **MUST** implement `onError` callback
|
|
61
|
+
- **MUST** implement `onSelectImage` callback
|
|
62
|
+
- **MUST** warn about file size increase
|
|
63
|
+
|
|
64
|
+
### 3. State Management
|
|
65
|
+
- **MUST** check `isReady` before enabling upscale button
|
|
66
|
+
- **MUST** display progress during upscaling
|
|
67
|
+
- **MUST** handle very large file sizes (4x can be 16x larger)
|
|
68
|
+
- **MUST** display `error` state with clear messages
|
|
69
|
+
- **MUST** implement proper cleanup on unmount
|
|
70
|
+
|
|
71
|
+
### 4. Performance
|
|
72
|
+
- **MUST** warn about 4x file sizes (can be very large)
|
|
73
|
+
- **MUST** show progress indicator for long operations
|
|
74
|
+
- **MUST** implement timeout (180s for 4x upscaling)
|
|
75
|
+
- **MUST** allow users to cancel processing
|
|
76
|
+
- **MUST** cache results locally to avoid re-processing
|
|
77
|
+
|
|
78
|
+
### 5. User Experience
|
|
79
|
+
- **MUST** show before/after comparison
|
|
80
|
+
- **MUST** display estimated output file size
|
|
81
|
+
- **MUST** warn about processing time
|
|
82
|
+
- **MUST** provide quality settings
|
|
83
|
+
- **MUST** handle large result downloads
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 🚫 Prohibitions (MUST AVOID)
|
|
88
|
+
|
|
89
|
+
### Strictly Forbidden
|
|
90
|
+
|
|
91
|
+
❌ **NEVER** do the following:
|
|
92
|
+
|
|
93
|
+
1. **No Missing Images**
|
|
94
|
+
- Always validate image is selected
|
|
95
|
+
- Never call process() without image
|
|
96
|
+
|
|
97
|
+
2. **No Auto-Processing**
|
|
98
|
+
- Never start upscaling without user action
|
|
99
|
+
- Always require explicit "Upscale" button press
|
|
100
|
+
- Show preview before processing
|
|
101
|
+
|
|
102
|
+
3. **No Ignoring File Sizes**
|
|
103
|
+
- Never hide file size warnings for 4x upscaling
|
|
104
|
+
- Always display estimated output size
|
|
105
|
+
- Warn about download times
|
|
106
|
+
|
|
107
|
+
4. **No Unhandled Errors**
|
|
108
|
+
- Never ignore upscaling failures
|
|
109
|
+
- Always explain what went wrong
|
|
110
|
+
- Provide retry or alternative options
|
|
111
|
+
|
|
112
|
+
5. **No Memory Leaks**
|
|
113
|
+
- Never keep both original and 4x upscaled in memory
|
|
114
|
+
- Clean up temporary images
|
|
115
|
+
- Implement proper image disposal
|
|
116
|
+
|
|
117
|
+
6. **No Blocking UI**
|
|
118
|
+
- Never block main thread with image processing
|
|
119
|
+
- Always show progress indicator
|
|
120
|
+
- Allow cancellation of long operations
|
|
121
|
+
|
|
122
|
+
7. **No Quality Loss**
|
|
123
|
+
- Never compress upscaled image excessively
|
|
124
|
+
- Use appropriate quality settings
|
|
125
|
+
- Preserve enhancement benefits
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 🤖 AI Agent Directions
|
|
130
|
+
|
|
131
|
+
### For AI Code Generation Tools
|
|
132
|
+
|
|
133
|
+
When using this feature with AI code generation tools, follow these guidelines:
|
|
134
|
+
|
|
135
|
+
#### Prompt Template for AI Agents
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
You are implementing an image upscaling feature using @umituz/react-native-ai-generation-content.
|
|
139
|
+
|
|
140
|
+
REQUIREMENTS:
|
|
141
|
+
1. Import from: @umituz/react-native-ai-generation-content
|
|
142
|
+
2. Use the useUpscaleFeature hook
|
|
143
|
+
3. Select scale factor (2x or 4x)
|
|
144
|
+
4. Implement image selection UI
|
|
145
|
+
5. Validate image before upscaling
|
|
146
|
+
6. Show before/after comparison
|
|
147
|
+
7. Warn about file sizes (especially 4x)
|
|
148
|
+
8. Handle long processing times with progress
|
|
149
|
+
9. Implement proper error handling
|
|
150
|
+
10. Implement cleanup on unmount
|
|
151
|
+
|
|
152
|
+
CRITICAL RULES:
|
|
153
|
+
- MUST validate image before calling upscale()
|
|
154
|
+
- MUST warn about 4x file sizes (can be 16x larger)
|
|
155
|
+
- MUST show before/after comparison
|
|
156
|
+
- MUST handle very large result files
|
|
157
|
+
- MUST implement debouncing (300ms)
|
|
158
|
+
- MUST allow cancellation of long operations
|
|
159
|
+
|
|
160
|
+
CONFIGURATION:
|
|
161
|
+
- Provide valid userId (string)
|
|
162
|
+
- Set scaleFactor: 2 | 4 (2 = double, 4 = quadruple)
|
|
163
|
+
- Implement onSelectImage callback
|
|
164
|
+
- Implement onSaveImage callback
|
|
165
|
+
- Configure callbacks: onProcessingStart, onProcessingComplete, onError
|
|
166
|
+
|
|
167
|
+
UPSCALING OPTIONS:
|
|
168
|
+
- scaleFactor: 2 | 4 (resolution multiplier)
|
|
169
|
+
- enhance: boolean (improve details during upscaling)
|
|
170
|
+
- denoise: boolean (remove noise and artifacts)
|
|
171
|
+
|
|
172
|
+
STRICTLY FORBIDDEN:
|
|
173
|
+
- No missing image validation
|
|
174
|
+
- No auto-processing without user action
|
|
175
|
+
- No ignoring file size warnings
|
|
176
|
+
- No unhandled errors
|
|
177
|
+
- No memory leaks with large images
|
|
178
|
+
- No blocking UI
|
|
179
|
+
- No excessive compression of results
|
|
180
|
+
|
|
181
|
+
QUALITY CHECKLIST:
|
|
182
|
+
- [ ] Image selection implemented
|
|
183
|
+
- [ ] Scale factor selector (2x, 4x)
|
|
184
|
+
- [ ] File size warning displayed
|
|
185
|
+
- [ ] Before/after comparison view
|
|
186
|
+
- [ ] Progress indicator for long operations
|
|
187
|
+
- [ ] Error display with retry option
|
|
188
|
+
- [ ] Download with format options
|
|
189
|
+
- [ ] Cancellation capability
|
|
190
|
+
- [ ] Original image preserved
|
|
107
191
|
```
|
|
108
192
|
|
|
109
|
-
|
|
193
|
+
#### AI Implementation Checklist
|
|
110
194
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
195
|
+
Use this checklist when generating code:
|
|
196
|
+
|
|
197
|
+
- [ ] Feature imported from correct path
|
|
198
|
+
- [ ] Image selection implemented
|
|
199
|
+
- [ ] Scale factor selector added (2x, 4x)
|
|
200
|
+
- [ ] Validation before upscale()
|
|
201
|
+
- [ ] File size warning displayed
|
|
202
|
+
- [ ] Before/after comparison view
|
|
203
|
+
- [ ] Progress indicator during processing
|
|
204
|
+
- [ ] Error display with user-friendly message
|
|
205
|
+
- [ ] Download functionality for large files
|
|
206
|
+
- [ ] Cancellation button available
|
|
207
|
+
- [ ] Cleanup on unmount
|
|
208
|
+
- [ ] Original image preserved
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## 🛠️ Configuration Strategy
|
|
213
|
+
|
|
214
|
+
### Essential Configuration
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
// Required fields
|
|
218
|
+
{
|
|
219
|
+
userId: string
|
|
220
|
+
scaleFactor: 2 | 4
|
|
221
|
+
onSelectImage: () => Promise<string | null>
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Optional callbacks
|
|
225
|
+
{
|
|
226
|
+
onProcessingStart?: () => void
|
|
227
|
+
onProcessingComplete?: (result) => void
|
|
228
|
+
onError?: (error: string) => void
|
|
116
229
|
}
|
|
117
230
|
```
|
|
118
231
|
|
|
119
|
-
|
|
232
|
+
### Recommended Settings
|
|
233
|
+
|
|
234
|
+
1. **Scale Factors**
|
|
235
|
+
- 2x: Double resolution (file size ~4x larger)
|
|
236
|
+
- 4x: Quadruple resolution (file size ~16x larger)
|
|
237
|
+
- Start with 2x, try 4x if needed
|
|
120
238
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
239
|
+
2. **Image Quality**
|
|
240
|
+
- Minimum input: 256x256 resolution
|
|
241
|
+
- Recommended input: 1024x1024 or higher
|
|
242
|
+
- Format: JPEG, PNG, or WebP
|
|
243
|
+
- Max input size: 10MB
|
|
126
244
|
|
|
127
|
-
|
|
245
|
+
3. **Performance Settings**
|
|
246
|
+
- Timeout: 180s for 4x upscaling
|
|
247
|
+
- Show progress for long operations
|
|
248
|
+
- Enable result caching
|
|
249
|
+
- Warn about download times
|
|
128
250
|
|
|
129
|
-
|
|
251
|
+
---
|
|
130
252
|
|
|
131
|
-
|
|
132
|
-
import { GridSelector } from '@umituz/react-native-ai-generation-content';
|
|
253
|
+
## 📊 State Management
|
|
133
254
|
|
|
134
|
-
|
|
135
|
-
{ id: '2x', name: '2x', description: 'Double resolution' },
|
|
136
|
-
{ id: '4x', name: '4x', description: 'Quadruple resolution' },
|
|
137
|
-
];
|
|
255
|
+
### Feature States
|
|
138
256
|
|
|
139
|
-
|
|
140
|
-
|
|
257
|
+
**isReady**: boolean
|
|
258
|
+
- Image selected and validated
|
|
259
|
+
- Check before enabling upscale button
|
|
141
260
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
261
|
+
**isProcessing**: boolean
|
|
262
|
+
- Upscaling in progress
|
|
263
|
+
- Show loading/progress indicator
|
|
264
|
+
- Disable upscale button
|
|
265
|
+
|
|
266
|
+
**progress**: number (0-100)
|
|
267
|
+
- Upscaling progress percentage
|
|
268
|
+
- Update progress bar
|
|
269
|
+
|
|
270
|
+
**error**: string | null
|
|
271
|
+
- Error message if upscaling failed
|
|
272
|
+
- Display to user with clear message
|
|
273
|
+
|
|
274
|
+
**result**: {
|
|
275
|
+
imageUrl: string
|
|
276
|
+
originalImageUrl?: string
|
|
277
|
+
scaleFactor?: number
|
|
278
|
+
outputSize?: { width: number; height: number }
|
|
279
|
+
metadata?: any
|
|
149
280
|
}
|
|
150
|
-
```
|
|
151
281
|
|
|
152
|
-
|
|
282
|
+
---
|
|
153
283
|
|
|
154
|
-
|
|
155
|
-
import { ResultDisplay } from '@umituz/react-native-ai-generation-content';
|
|
284
|
+
## 🎨 Best Practices
|
|
156
285
|
|
|
157
|
-
|
|
158
|
-
<View>
|
|
159
|
-
<Text>Before:</Text>
|
|
160
|
-
<Image source={{ uri: originalImage }} style={{ width: 200, height: 200 }} />
|
|
286
|
+
### Image Selection
|
|
161
287
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
)}
|
|
166
|
-
```
|
|
288
|
+
1. **Input Quality**
|
|
289
|
+
- Good: Reasonable quality source images
|
|
290
|
+
- Bad: Extremely low resolution (<256px) or very compressed
|
|
167
291
|
|
|
168
|
-
|
|
292
|
+
2. **Scale Factor Choice**
|
|
293
|
+
- Start with 2x for most cases
|
|
294
|
+
- Use 4x for print or large displays
|
|
295
|
+
- Consider file size implications
|
|
169
296
|
|
|
170
|
-
|
|
297
|
+
3. **Enhancement Options**
|
|
298
|
+
- Enable enhance for better detail preservation
|
|
299
|
+
- Use denoise for noisy source images
|
|
300
|
+
- Both options recommended for best quality
|
|
171
301
|
|
|
172
|
-
|
|
173
|
-
const result = await feature.process({
|
|
174
|
-
scaleFactor: 4,
|
|
175
|
-
enhance: true,
|
|
176
|
-
denoise: true,
|
|
177
|
-
});
|
|
178
|
-
```
|
|
302
|
+
### User Experience
|
|
179
303
|
|
|
180
|
-
|
|
304
|
+
1. **File Size Warnings**
|
|
305
|
+
- Clearly show estimated output file size
|
|
306
|
+
- Warn about download times for 4x
|
|
307
|
+
- Provide quality vs size options
|
|
181
308
|
|
|
182
|
-
|
|
183
|
-
|
|
309
|
+
2. **Progress Feedback**
|
|
310
|
+
- Show estimated time remaining
|
|
311
|
+
- Update progress regularly
|
|
312
|
+
- Allow cancellation for long operations
|
|
184
313
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}, [state.progress]);
|
|
190
|
-
```
|
|
314
|
+
3. **Comparison Tools**
|
|
315
|
+
- Side-by-side comparison
|
|
316
|
+
- Zoom capability for detail inspection
|
|
317
|
+
- Pixel-level comparison (optional)
|
|
191
318
|
|
|
192
|
-
|
|
319
|
+
---
|
|
193
320
|
|
|
194
|
-
|
|
321
|
+
## 🐛 Common Pitfalls
|
|
195
322
|
|
|
196
|
-
|
|
197
|
-
// Upscale old photos for better quality
|
|
198
|
-
const result = await feature.process({ scaleFactor: 2 });
|
|
199
|
-
```
|
|
323
|
+
### Quality Issues
|
|
200
324
|
|
|
201
|
-
|
|
325
|
+
❌ **Problem**: Upscaled image looks blurry
|
|
326
|
+
✅ **Solution**: Enable enhance option, try higher quality source
|
|
202
327
|
|
|
203
|
-
|
|
204
|
-
// Upscale to print-ready resolution
|
|
205
|
-
const result = await feature.process({ scaleFactor: 4 });
|
|
206
|
-
```
|
|
328
|
+
### File Size Issues
|
|
207
329
|
|
|
208
|
-
|
|
330
|
+
❌ **Problem**: 4x file too large to handle
|
|
331
|
+
✅ **Solution**: Warn users, allow 2x option, compress appropriately
|
|
209
332
|
|
|
210
|
-
|
|
211
|
-
// Upscale with enhancement and denoising
|
|
212
|
-
const result = await feature.process({
|
|
213
|
-
scaleFactor: 2,
|
|
214
|
-
enhance: true,
|
|
215
|
-
denoise: true,
|
|
216
|
-
});
|
|
217
|
-
```
|
|
333
|
+
### Performance Issues
|
|
218
334
|
|
|
219
|
-
|
|
335
|
+
❌ **Problem**: Very slow upscaling
|
|
336
|
+
✅ **Solution**: Show progress, allow cancellation, implement timeout
|
|
220
337
|
|
|
221
|
-
|
|
222
|
-
2. **Image Quality**: Higher quality source images produce better results
|
|
223
|
-
3. **File Size**: Be aware that 4x upscaling significantly increases file size
|
|
224
|
-
4. **Enhancement**: Use enhancement for better detail preservation
|
|
225
|
-
5. **Testing**: Test different scale factors to find the best result
|
|
338
|
+
### Memory Issues
|
|
226
339
|
|
|
227
|
-
|
|
340
|
+
❌ **Problem**: App crashes with large upscales
|
|
341
|
+
✅ **Solution**: Clean up original image, stream download, optimize memory
|
|
228
342
|
|
|
229
|
-
|
|
230
|
-
const { state, process } = useUpscaleFeature({ ...config });
|
|
343
|
+
---
|
|
231
344
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
345
|
+
## 📦 Related Components
|
|
346
|
+
|
|
347
|
+
Use these components from the library:
|
|
348
|
+
|
|
349
|
+
- **PhotoUploadCard**: Upload image interface
|
|
350
|
+
- **ResultDisplay**: Before/after comparison
|
|
351
|
+
- **ScaleFactorSelector**: Choose 2x or 4x
|
|
352
|
+
- **ProgressBar**: Progress display
|
|
353
|
+
- **ImageComparison**: Side-by-side comparison
|
|
354
|
+
|
|
355
|
+
Located at: `src/presentation/components/`
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
359
|
+
## 🔄 Migration Strategy
|
|
360
|
+
|
|
361
|
+
If migrating from previous implementation:
|
|
362
|
+
|
|
363
|
+
1. **Update imports** to new path
|
|
364
|
+
2. **Add scale factor selector** (2x, 4x)
|
|
365
|
+
3. **Implement file size warnings**
|
|
366
|
+
4. **Update state handling** for new structure
|
|
367
|
+
5. **Add before/after comparison**
|
|
368
|
+
6. **Test with large files**
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## 📚 Additional Resources
|
|
373
|
+
|
|
374
|
+
- Main documentation: `/docs/`
|
|
375
|
+
- API reference: `/docs/api/`
|
|
376
|
+
- Examples: `/docs/examples/basic/upscaling/`
|
|
377
|
+
- Architecture: `/ARCHITECTURE.md`
|
|
378
|
+
|
|
379
|
+
---
|
|
380
|
+
|
|
381
|
+
**Last Updated**: 2025-01-08
|
|
382
|
+
**Version**: 2.0.0 (Strategy-based Documentation)
|
|
238
383
|
|
|
239
|
-
|
|
384
|
+
---
|
|
240
385
|
|
|
241
|
-
|
|
242
|
-
- [Photo Restoration](../photo-restoration) - Restore old/blurry photos
|
|
243
|
-
- [Image to Image](../image-to-image) - Transform images using AI
|
|
386
|
+
## 📝 Changelog
|
|
244
387
|
|
|
245
|
-
|
|
388
|
+
### v2.0.0 - 2025-01-08
|
|
389
|
+
- **BREAKING**: Documentation format changed to strategy-based
|
|
390
|
+
- Removed extensive code examples
|
|
391
|
+
- Added rules, prohibitions, and AI agent directions
|
|
392
|
+
- Focus on best practices and implementation guidance
|
|
393
|
+
- Added file size handling guidelines
|
|
246
394
|
|
|
247
|
-
|
|
395
|
+
### v1.0.0 - Initial Release
|
|
396
|
+
- Initial feature documentation
|