@umituz/react-native-ai-generation-content 1.17.231 → 1.17.233

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.
Files changed (31) hide show
  1. package/README.md +236 -261
  2. package/package.json +1 -1
  3. package/src/domains/content-moderation/README.md +239 -296
  4. package/src/domains/creations/README.md +242 -325
  5. package/src/domains/face-detection/README.md +228 -307
  6. package/src/domains/prompts/README.md +242 -312
  7. package/src/features/ai-hug/README.md +381 -219
  8. package/src/features/ai-kiss/README.md +388 -219
  9. package/src/features/anime-selfie/README.md +327 -256
  10. package/src/features/audio-generation/README.md +352 -309
  11. package/src/features/colorization/README.md +332 -228
  12. package/src/features/couple-future/README.md +387 -212
  13. package/src/features/future-prediction/README.md +391 -221
  14. package/src/features/hd-touch-up/README.md +339 -252
  15. package/src/features/image-captioning/README.md +359 -299
  16. package/src/features/image-to-image/README.md +398 -357
  17. package/src/features/image-to-video/README.md +337 -292
  18. package/src/features/inpainting/README.md +348 -244
  19. package/src/features/meme-generator/README.md +350 -269
  20. package/src/features/photo-restoration/README.md +338 -225
  21. package/src/features/remove-background/README.md +335 -234
  22. package/src/features/remove-object/README.md +341 -288
  23. package/src/features/replace-background/README.md +353 -236
  24. package/src/features/script-generator/README.md +358 -287
  25. package/src/features/shared/README.md +254 -223
  26. package/src/features/sketch-to-image/README.md +331 -234
  27. package/src/features/style-transfer/README.md +336 -237
  28. package/src/features/text-to-video/README.md +360 -193
  29. package/src/features/text-to-voice/README.md +382 -272
  30. package/src/features/upscaling/README.md +340 -191
  31. package/src/presentation/components/result/ResultStoryCard.tsx +1 -1
@@ -1,288 +1,405 @@
1
- # Replace Background
1
+ # Replace Background Feature
2
2
 
3
3
  Replace image backgrounds with new scenes using AI.
4
4
 
5
- ## Features
5
+ ## 📍 Import Path
6
6
 
7
- - Remove existing background
8
- - Replace with custom backgrounds
9
- - Built-in background templates
10
- - Upload custom background images
11
- - Natural edge blending
7
+ ```typescript
8
+ import { useReplaceBackgroundFeature } from '@umituz/react-native-ai-generation-content';
9
+ ```
12
10
 
13
- ## Installation
11
+ **Location**: `src/features/replace-background/`
14
12
 
15
- This feature is part of `@umituz/react-native-ai-generation-content`.
13
+ ## 🎯 Feature Purpose
16
14
 
17
- ```bash
18
- npm install @umituz/react-native-ai-generation-content
19
- ```
15
+ Remove existing backgrounds from images and replace them with custom backgrounds or built-in templates. Features automatic subject detection, natural edge blending, and optional lighting/color matching for seamless results.
20
16
 
21
- ## Basic Usage
17
+ ---
22
18
 
23
- ### Using the Hook
19
+ ## 📋 Usage Strategy
24
20
 
25
- ```tsx
26
- import { useReplaceBackgroundFeature } from '@umituz/react-native-ai-generation-content';
27
- import * as ImagePicker from 'react-native-image-picker';
28
-
29
- function ReplaceBackgroundScreen() {
30
- const [foreground, setForeground] = useState<string | null>(null);
31
- const [background, setBackground] = useState<string | null>(null);
32
-
33
- const feature = useReplaceBackgroundFeature({
34
- config: {
35
- edgeSmoothness: 'medium',
36
- onProcessingStart: () => console.log('Replacing background...'),
37
- onProcessingComplete: (result) => console.log('Complete:', result),
38
- onError: (error) => console.error('Error:', error),
39
- },
40
- onSelectForeground: async () => {
41
- const result = await ImagePicker.launchImageLibrary({ mediaType: 'photo' });
42
- if (result.assets && result.assets[0].uri) {
43
- const base64 = await convertToBase64(result.assets[0].uri);
44
- setForeground(base64);
45
- return base64;
46
- }
47
- return null;
48
- },
49
- onSelectBackground: async () => {
50
- const result = await ImagePicker.launchImageLibrary({ mediaType: 'photo' });
51
- if (result.assets && result.assets[0].uri) {
52
- const base64 = await convertToBase64(result.assets[0].uri);
53
- setBackground(base64);
54
- return base64;
55
- }
56
- return null;
57
- },
58
- onSaveResult: async (imageUrl) => {
59
- await saveToGallery(imageUrl);
60
- },
61
- });
62
-
63
- return (
64
- <View>
65
- <PhotoUploadCard
66
- image={foreground}
67
- onSelectImage={feature.selectForeground}
68
- title="Select Foreground Image"
69
- />
70
-
71
- <PhotoUploadCard
72
- image={background}
73
- onSelectImage={feature.selectBackground}
74
- title="Select New Background"
75
- />
76
-
77
- <Button
78
- title="Replace Background"
79
- onPress={feature.process}
80
- disabled={!feature.isReady || feature.state.isProcessing}
81
- />
82
-
83
- {feature.state.isProcessing && (
84
- <ActivityIndicator />
85
- )}
86
-
87
- {feature.state.result && (
88
- <Image source={{ uri: feature.state.result.imageUrl }} />
89
- )}
90
- </View>
91
- );
92
- }
93
- ```
21
+ ### When to Use This Feature
94
22
 
95
- ### Using the Unified AI Feature Screen
23
+ **Use Cases:**
24
+ - Creating professional photos with studio backgrounds
25
+ - Adding travel backgrounds to portraits
26
+ - Creating product photos with clean backgrounds
27
+ - Creative background replacements for social media
28
+ - Replacing distracting backgrounds
96
29
 
97
- ```tsx
98
- import { AIFeatureScreen } from '@umituz/react-native-ai-generation-content';
30
+ ❌ **When NOT to Use:**
31
+ - Simple background removal (use Remove Background)
32
+ - Removing objects from images (use Remove Object)
33
+ - Background removal without replacement (use Remove Background)
34
+
35
+ ### Implementation Strategy
36
+
37
+ 1. **Select foreground image** with subject
38
+ 2. **Select new background** (upload or template)
39
+ 3. **Configure options** (edge smoothness, lighting, colors)
40
+ 4. **Process replacement** with progress tracking
41
+ 5. **Preview result** and offer regeneration
42
+ 6. **Save or share** final image
43
+
44
+ ---
45
+
46
+ ## ⚠️ Critical Rules (MUST FOLLOW)
47
+
48
+ ### 1. Image Requirements
49
+ - **MUST** provide TWO images (foreground + background)
50
+ - **MUST** use high-quality images (min 512x512 recommended)
51
+ - **MUST** have clear subject in foreground
52
+ - **MUST NOT** exceed file size limits (10MB each)
53
+ - **MUST** validate both images before processing
54
+
55
+ ### 2. Configuration
56
+ - **MUST** provide valid `userId` for tracking
57
+ - **MUST** specify `edgeSmoothness` (low, medium, high)
58
+ - **MUST** implement `onError` callback
59
+ - **MUST** implement `onSelectForeground` callback
60
+ - **MUST** implement `onSelectBackground` callback
61
+
62
+ ### 3. State Management
63
+ - **MUST** check `isReady` before enabling replace button
64
+ - **MUST** verify both images are selected
65
+ - **MUST** display progress during replacement
66
+ - **MUST** display `error` state with clear messages
67
+ - **MUST** implement proper cleanup on unmount
68
+
69
+ ### 4. Performance
70
+ - **MUST** implement image compression before upload
71
+ - **MUST** show progress indicator for processing
72
+ - **MUST** cache results locally
73
+ - **MUST** allow users to cancel processing
74
+ - **MUST NOT** replace multiple backgrounds simultaneously
75
+
76
+ ### 5. Quality Options
77
+ - **MUST** provide edge smoothness control
78
+ - **MUST** support lighting adjustment
79
+ - **MUST** support color matching
80
+ - **MUST** offer background blur option
81
+ - **MUST** handle various image types
82
+
83
+ ---
84
+
85
+ ## 🚫 Prohibitions (MUST AVOID)
86
+
87
+ ### Strictly Forbidden
88
+
89
+ ❌ **NEVER** do the following:
90
+
91
+ 1. **No Missing Images**
92
+ - Always validate both foreground and background are selected
93
+ - Never call process() without both images
94
+
95
+ 2. **No Auto-Processing**
96
+ - Never start replacement without user action
97
+ - Always require explicit "Replace" button press
98
+ - Show preview before processing
99
+
100
+ 3. **No Hardcoded Credentials**
101
+ - Never store API keys in component files
102
+ - Use environment variables or secure storage
103
+
104
+ 4. **No Unhandled Errors**
105
+ - Never ignore replacement failures
106
+ - Always explain what went wrong
107
+ - Provide retry or alternative options
108
+
109
+ 5. **No Memory Leaks**
110
+ - Never store all images simultaneously in state
111
+ - Clean up temporary images
112
+ - Implement proper image disposal
113
+
114
+ 6. **No Blocked UI**
115
+ - Never block main thread with image processing
116
+ - Always show progress indicator
117
+ - Allow cancellation
118
+
119
+ 7. **No Perspective Mismatch**
120
+ - Never warn about perspective mismatches between images
121
+ - Always provide guidance on background selection
122
+ - Show preview before final processing
123
+
124
+ ---
125
+
126
+ ## 🤖 AI Agent Directions
127
+
128
+ ### For AI Code Generation Tools
129
+
130
+ When using this feature with AI code generation tools, follow these guidelines:
131
+
132
+ #### Prompt Template for AI Agents
99
133
 
100
- function App() {
101
- return (
102
- <AIFeatureScreen
103
- featureId="replace-background"
104
- userId="user-123"
105
- />
106
- );
107
- }
108
134
  ```
135
+ You are implementing a replace background feature using @umituz/react-native-ai-generation-content.
136
+
137
+ REQUIREMENTS:
138
+ 1. Import from: @umituz/react-native-ai-generation-content
139
+ 2. Use the useReplaceBackgroundFeature hook
140
+ 3. Implement dual image selection (foreground + background)
141
+ 4. Provide background templates or custom upload
142
+ 5. Set edge smoothness level (low, medium, high)
143
+ 6. Configure options (adjustLighting, adjustColors, blurBackground)
144
+ 7. Validate both images before processing
145
+ 8. Show result preview
146
+ 9. Handle long processing times with progress
147
+ 10. Implement proper error handling
148
+ 11. Implement cleanup on unmount
149
+
150
+ CRITICAL RULES:
151
+ - MUST validate both foreground and background images before calling process()
152
+ - MUST provide clear UI for foreground vs background selection
153
+ - MUST show result preview with quality check
154
+ - MUST handle edge smoothness adjustment
155
+ - MUST implement debouncing (300ms)
156
+ - MUST allow background regeneration
157
+
158
+ CONFIGURATION:
159
+ - Provide valid userId (string)
160
+ - Set edgeSmoothness: 'low' | 'medium' | 'high'
161
+ - Set adjustLighting: boolean (match foreground/background lighting)
162
+ - Set adjustColors: boolean (color-grade foreground to match background)
163
+ - Set blurBackground: boolean (add blur for depth effect)
164
+ - Implement onSelectForeground callback
165
+ - Implement onSelectBackground callback
166
+ - Implement onSaveResult callback
167
+ - Configure callbacks: onProcessingStart, onProcessingComplete, onError
168
+
169
+ OPTIONS:
170
+ - edgeSmoothness: Edge blending quality
171
+ - adjustLighting: Match lighting between images
172
+ - adjustColors: Harmonize colors
173
+ - blurBackground: Add depth with background blur
174
+
175
+ STRICTLY FORBIDDEN:
176
+ - No missing image validation (both images required)
177
+ - No auto-processing without user action
178
+ - No hardcoded API keys
179
+ - No unhandled errors
180
+ - No memory leaks
181
+ - No blocking UI
182
+ - No perspective mismatch warnings
183
+
184
+ QUALITY CHECKLIST:
185
+ - [ ] Foreground selection implemented
186
+ - [ ] Background selection/template picker added
187
+ - [ ] Edge smoothness selector included
188
+ - [ ] Lighting/color adjustment toggles
189
+ - [ ] Validation before process() (both images)
190
+ - [ ] Result preview display
191
+ - [ ] Progress indicator during processing
192
+ - [ ] Error display with retry option
193
+ - [ ] Download/share functionality
194
+ - [ ] Background template library
195
+ ```
196
+
197
+ #### AI Implementation Checklist
109
198
 
110
- ## Configuration Options
199
+ Use this checklist when generating code:
111
200
 
112
- ### Feature Config
201
+ - [ ] Feature imported from correct path
202
+ - [ ] Dual image selection implemented
203
+ - [ ] Background templates provided
204
+ - [ ] Edge smoothness selector added
205
+ - [ ] Lighting/color adjustment toggles
206
+ - [ ] Validation before process() (both images)
207
+ - [ ] Result preview display
208
+ - [ ] Progress indicator during processing
209
+ - [ ] Error display with user-friendly message
210
+ - [ ] Download/share buttons
211
+ - [ ] Cleanup on unmount
212
+ - [ ] Original images preserved
113
213
 
114
- ```tsx
115
- interface ReplaceBackgroundFeatureConfig {
116
- edgeSmoothness?: 'low' | 'medium' | 'high';
117
- adjustLighting?: boolean; // Match lighting between images
118
- onProcessingStart?: () => void;
119
- onProcessingComplete?: (result: ReplaceBackgroundResult) => void;
120
- onError?: (error: string) => void;
214
+ ---
215
+
216
+ ## 🛠️ Configuration Strategy
217
+
218
+ ### Essential Configuration
219
+
220
+ ```typescript
221
+ // Required fields
222
+ {
223
+ userId: string
224
+ edgeSmoothness: 'low' | 'medium' | 'high'
225
+ onSelectForeground: () => Promise<string | null>
226
+ onSelectBackground: () => Promise<string | null>
227
+ }
228
+
229
+ // Optional callbacks
230
+ {
231
+ onProcessingStart?: () => void
232
+ onProcessingComplete?: (result) => void
233
+ onError?: (error: string) => void
121
234
  }
122
235
  ```
123
236
 
124
- ### Processing Options
237
+ ### Recommended Settings
238
+
239
+ 1. **Edge Smoothness**
240
+ - Low: Sharp, precise edges (products, objects)
241
+ - Medium: Balanced edges (portraits, general use)
242
+ - High: Soft, blended edges (artistic effects)
243
+
244
+ 2. **Quality Options**
245
+ - adjustLighting: Match foreground/background lighting
246
+ - adjustColors: Color-grade foreground to match background
247
+ - blurBackground: Add blur for depth effect
248
+
249
+ 3. **Image Quality**
250
+ - Minimum: 512x512 resolution
251
+ - Recommended: 1024x1024 or higher
252
+ - Format: JPEG or PNG
253
+ - Max size: 10MB each
254
+
255
+ 4. **Background Selection**
256
+ - Use backgrounds with similar perspective
257
+ - Match lighting direction when possible
258
+ - Consider color harmony
125
259
 
126
- ```tsx
127
- interface ReplaceBackgroundOptions {
128
- edgeSmoothness: 'low' | 'medium' | 'high';
129
- adjustLighting?: boolean; // Match foreground and background lighting
130
- adjustColors?: boolean; // Color-grade foreground to match background
131
- blurBackground?: boolean; // Add blur to background for depth effect
260
+ ---
261
+
262
+ ## 📊 State Management
263
+
264
+ ### Feature States
265
+
266
+ **isReady**: boolean
267
+ - Both images selected and validated
268
+ - Check before enabling replace button
269
+
270
+ **isProcessing**: boolean
271
+ - Background replacement in progress
272
+ - Show loading/progress indicator
273
+ - Disable replace button
274
+
275
+ **progress**: number (0-100)
276
+ - Replacement progress percentage
277
+ - Update progress bar
278
+
279
+ **error**: string | null
280
+ - Error message if replacement failed
281
+ - Display to user with clear message
282
+
283
+ **result**: {
284
+ imageUrl: string
285
+ foregroundImageUrl?: string
286
+ backgroundImageUrl?: string
287
+ edgeSmoothness?: string
288
+ metadata?: any
132
289
  }
133
- ```
134
290
 
135
- ## Usage Flow
136
-
137
- 1. Select **Foreground** - Choose the main subject image
138
- 2. Select **Background** - Choose new background image
139
- 3. Configure **Options** - Adjust edge smoothness and other settings
140
- 4. Tap **Replace** - Start the replacement process
141
- 5. View **Result** - See the combined image
142
- 6. Save or Share - Save or share the result
143
-
144
- ## Component Examples
145
-
146
- ### Background Templates
147
-
148
- ```tsx
149
- import { StylePresetsGrid } from '@umituz/react-native-ai-generation-content';
150
-
151
- const backgrounds = [
152
- { id: 'beach', name: 'Beach', preview: 'https://...' },
153
- { id: 'city', name: 'City', preview: 'https://...' },
154
- { id: 'nature', name: 'Nature', preview: 'https://...' },
155
- { id: 'studio', name: 'Studio', preview: 'https://...' },
156
- ];
157
-
158
- <StylePresetsGrid
159
- styles={backgrounds}
160
- selectedStyle={selectedBackground}
161
- onSelectStyle={async (bg) => {
162
- const bgImage = await downloadBackground(bg.preview);
163
- setBackground(bgImage);
164
- }}
165
- />
166
- ```
291
+ ---
167
292
 
168
- ### Edge Smoothness Selector
293
+ ## 🎨 Best Practices
169
294
 
170
- ```tsx
171
- import { GridSelector } from '@umituz/react-native-ai-generation-content';
295
+ ### Background Selection
172
296
 
173
- const smoothnessOptions = [
174
- { id: 'low', name: 'Sharp', description: 'Precise edges' },
175
- { id: 'medium', name: 'Balanced', description: 'Natural edges' },
176
- { id: 'high', name: 'Smooth', description: 'Soft edges' },
177
- ];
297
+ 1. **Perspective Matching**
298
+ - Good: Similar perspective and angle
299
+ - Bad: Conflicting perspectives
178
300
 
179
- <GridSelector
180
- options={smoothnessOptions}
181
- selectedOption={smoothness}
182
- onSelectOption={setSmoothness}
183
- />
184
- ```
301
+ 2. **Lighting Considerations**
302
+ - Enable adjustLighting for natural results
303
+ - Match lighting direction when possible
304
+ - Consider time of day
185
305
 
186
- ### Lighting Toggle
306
+ 3. **Color Harmony**
307
+ - Use adjustColors for better integration
308
+ - Consider complementary colors
309
+ - Test different backgrounds
187
310
 
188
- ```tsx
189
- import { Switch } from 'react-native';
311
+ ### User Experience
190
312
 
191
- <Switch
192
- value={adjustLighting}
193
- onValueChange={setAdjustLighting}
194
- />
313
+ 1. **Background Templates**
314
+ - Provide curated background options
315
+ - Categorize by use case (studio, travel, nature, etc.)
316
+ - Show previews before selection
195
317
 
196
- <Text>Match Lighting</Text>
197
- ```
318
+ 2. **Preview**
319
+ - Show combined result before saving
320
+ - Allow option adjustment
321
+ - Compare with original
198
322
 
199
- ## Advanced Usage
323
+ 3. **Quality Settings**
324
+ - Explain edge smoothness options
325
+ - Provide presets (portrait, product, creative)
326
+ - Allow fine-tuning
200
327
 
201
- ### Custom Options
328
+ ---
202
329
 
203
- ```tsx
204
- const result = await feature.process({
205
- edgeSmoothness: 'medium',
206
- adjustLighting: true,
207
- adjustColors: true,
208
- blurBackground: false,
209
- });
210
- ```
330
+ ## 🐛 Common Pitfalls
211
331
 
212
- ### Preset Backgrounds
332
+ ### Perspective Issues
213
333
 
214
- ```tsx
215
- const PRESET_BACKGROUNDS = {
216
- beach: 'https://example.com/bg/beach.jpg',
217
- city: 'https://example.com/bg/city.jpg',
218
- studio: 'https://example.com/bg/studio.jpg',
219
- nature: 'https://example.com/bg/nature.jpg',
220
- };
334
+ ❌ **Problem**: Unnatural looking result due to perspective mismatch
335
+ **Solution**: Choose background with similar perspective
221
336
 
222
- const result = await feature.process({
223
- background: PRESET_BACKGROUNDS.beach,
224
- edgeSmoothness: 'medium',
225
- });
226
- ```
337
+ ### Edge Issues
227
338
 
228
- ## Use Cases
339
+ **Problem**: Visible edges around subject
340
+ ✅ **Solution**: Adjust edge smoothness, enable lighting/color adjustment
229
341
 
230
- ### Professional Photos
342
+ ### Quality Issues
231
343
 
232
- ```tsx
233
- // Replace with professional studio background
234
- const result = await feature.process({
235
- background: studioBackground,
236
- adjustLighting: true,
237
- adjustColors: true,
238
- });
239
- ```
344
+ ❌ **Problem**: Poor subject detection
345
+ **Solution**: Use higher quality foreground image with clear subject
240
346
 
241
- ### Travel Photos
347
+ ### Lighting Issues
242
348
 
243
- ```tsx
244
- // Add exotic travel backgrounds
245
- const result = await feature.process({
246
- background: beachBackground,
247
- edgeSmoothness: 'high',
248
- });
249
- ```
349
+ ❌ **Problem**: Lighting doesn't match between images
350
+ **Solution**: Enable adjustLighting and adjustColors options
250
351
 
251
- ### Creative Effects
352
+ ---
252
353
 
253
- ```tsx
254
- // Create fantasy backgrounds
255
- const result = await feature.process({
256
- background: fantasyBackground,
257
- blurBackground: true,
258
- });
259
- ```
354
+ ## 📦 Related Components
260
355
 
261
- ### Product Photos
356
+ Use these components from the library:
262
357
 
263
- ```tsx
264
- // Clean white background for products
265
- const result = await feature.process({
266
- background: whiteBackground,
267
- edgeSmoothness: 'low',
268
- adjustLighting: true,
269
- });
270
- ```
358
+ - **PhotoUploadCard**: Upload image interface
359
+ - **DualImagePicker**: Select foreground and background
360
+ - **BackgroundTemplates**: Pre-made background options
361
+ - **EdgeSmoothnessSelector**: Choose edge quality
362
+ - **ResultDisplay**: Show combined result
363
+ - **ProgressBar**: Progress display
364
+
365
+ Located at: `src/presentation/components/`
366
+
367
+ ---
368
+
369
+ ## 🔄 Migration Strategy
370
+
371
+ If migrating from previous implementation:
372
+
373
+ 1. **Update imports** to new path
374
+ 2. **Add dual image selection** (foreground + background)
375
+ 3. **Implement edge smoothness control**
376
+ 4. **Add quality options** (lighting, color, blur)
377
+ 5. **Update state handling** for both images
378
+ 6. **Test all edge smoothness levels**
379
+
380
+ ---
381
+
382
+ ## 📚 Additional Resources
383
+
384
+ - Main documentation: `/docs/`
385
+ - API reference: `/docs/api/`
386
+ - Examples: `/docs/examples/basic/replace-background/`
387
+ - Architecture: `/ARCHITECTURE.md`
271
388
 
272
- ## Best Practices
389
+ ---
273
390
 
274
- 1. **Foreground Quality**: Use high-quality images with clear subjects
275
- 2. **Background Match**: Choose backgrounds with similar perspective
276
- 3. **Edge Smoothness**: Higher values for portraits, lower for products
277
- 4. **Lighting**: Enable lighting adjustment for more natural results
278
- 5. **Colors**: Use color adjustment for better foreground/background harmony
391
+ **Last Updated**: 2025-01-08
392
+ **Version**: 2.0.0 (Strategy-based Documentation)
279
393
 
280
- ## Related Features
394
+ ---
281
395
 
282
- - [Remove Background](../remove-background) - Remove backgrounds
283
- - [Remove Object](../remove-object) - Remove unwanted objects
284
- - [Image to Image](../image-to-image) - Transform images with AI
396
+ ## 📝 Changelog
285
397
 
286
- ## License
398
+ ### v2.0.0 - 2025-01-08
399
+ - **BREAKING**: Documentation format changed to strategy-based
400
+ - Removed extensive code examples
401
+ - Added rules, prohibitions, and AI agent directions
402
+ - Focus on best practices and implementation guidance
287
403
 
288
- MIT
404
+ ### v1.0.0 - Initial Release
405
+ - Initial feature documentation