@umituz/react-native-ai-generation-content 1.17.232 → 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 (28) 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/remove-background/README.md +335 -234
  21. package/src/features/remove-object/README.md +341 -288
  22. package/src/features/replace-background/README.md +353 -236
  23. package/src/features/script-generator/README.md +358 -287
  24. package/src/features/shared/README.md +254 -223
  25. package/src/features/sketch-to-image/README.md +331 -234
  26. package/src/features/style-transfer/README.md +336 -237
  27. package/src/features/text-to-video/README.md +360 -193
  28. package/src/features/text-to-voice/README.md +382 -272
@@ -1,292 +1,393 @@
1
- # Remove Background
1
+ # Remove Background Feature
2
2
 
3
3
  Remove backgrounds from images using AI with precision.
4
4
 
5
- ## Features
5
+ ## 📍 Import Path
6
6
 
7
- - Automatic background detection and removal
8
- - Keep main subject while removing background
9
- - Support for complex subjects (hair, fur, transparent objects)
10
- - Fine-tune edges for professional results
11
- - Export as transparent PNG
7
+ ```typescript
8
+ import { useRemoveBackgroundFeature } from '@umituz/react-native-ai-generation-content';
9
+ ```
12
10
 
13
- ## Installation
11
+ **Location**: `src/features/remove-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
+ Automatically detect and remove backgrounds from images using AI. Keeps main subjects while removing backgrounds, handling complex edges like hair, fur, and transparent objects.
20
16
 
21
- ## Basic Usage
17
+ ---
22
18
 
23
- ### Using the Hook
19
+ ## 📋 Usage Strategy
24
20
 
25
- ```tsx
26
- import { useRemoveBackgroundFeature } from '@umituz/react-native-ai-generation-content';
27
- import * as ImagePicker from 'react-native-image-picker';
28
-
29
- function RemoveBackgroundScreen() {
30
- const [image, setImage] = useState<string | null>(null);
31
-
32
- const feature = useRemoveBackgroundFeature({
33
- config: {
34
- edgeSmoothness: 'medium',
35
- onProcessingStart: () => console.log('Removing background...'),
36
- onProcessingComplete: (result) => console.log('Complete:', result),
37
- onError: (error) => console.error('Error:', error),
38
- },
39
- onSelectImage: 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
- setImage(base64);
44
- return base64;
45
- }
46
- return null;
47
- },
48
- onSaveImage: async (imageUrl) => {
49
- await saveToGallery(imageUrl);
50
- },
51
- });
52
-
53
- return (
54
- <View>
55
- <PhotoUploadCard
56
- image={image}
57
- onSelectImage={feature.selectImage}
58
- title="Select Image to Remove Background"
59
- />
60
-
61
- <Button
62
- title="Remove Background"
63
- onPress={feature.process}
64
- disabled={!feature.isReady || feature.state.isProcessing}
65
- />
66
-
67
- {feature.state.isProcessing && (
68
- <ActivityIndicator />
69
- )}
70
-
71
- {feature.state.result && (
72
- <ResultDisplay
73
- originalImage={image}
74
- resultImage={feature.state.result.imageUrl}
75
- onSave={() => feature.saveResult()}
76
- showTransparentBackground
77
- />
78
- )}
79
- </View>
80
- );
81
- }
82
- ```
21
+ ### When to Use This Feature
83
22
 
84
- ### Using the Unified AI Feature Screen
23
+ **Use Cases:**
24
+ - Product photography for e-commerce
25
+ - Creating transparent images for design
26
+ - Profile picture background removal
27
+ - Preparing images for marketing materials
28
+ - Isolating subjects for compositing
29
+ - Creating stickers and overlays
85
30
 
86
- ```tsx
87
- import { AIFeatureScreen } from '@umituz/react-native-ai-generation-content';
31
+ ❌ **When NOT to Use:**
32
+ - Manual background selection (use image editing software)
33
+ - Background replacement (use Replace Background)
34
+ - Object removal from photos (use Remove Object)
35
+ - Photo restoration (use Photo Restoration)
88
36
 
89
- function App() {
90
- return (
91
- <AIFeatureScreen
92
- featureId="remove-background"
93
- userId="user-123"
94
- />
95
- );
96
- }
97
- ```
37
+ ### Implementation Strategy
98
38
 
99
- ## Configuration Options
39
+ 1. **Upload image** with clear subject
40
+ 2. **Preview detection** before processing
41
+ 3. **Choose edge smoothness** level
42
+ 4. **Show before/after comparison** with transparency
43
+ 5. **Provide download** as transparent PNG
44
+ 6. **Offer fine-tuning** options for edges
100
45
 
101
- ### Feature Config
46
+ ---
102
47
 
103
- ```tsx
104
- interface RemoveBackgroundFeatureConfig {
105
- edgeSmoothness?: 'low' | 'medium' | 'high';
106
- returnMask?: boolean; // Return the mask along with result
107
- onProcessingStart?: () => void;
108
- onProcessingComplete?: (result: RemoveBackgroundResult) => void;
109
- onError?: (error: string) => void;
110
- }
111
- ```
48
+ ## ⚠️ Critical Rules (MUST FOLLOW)
112
49
 
113
- ### Processing Options
50
+ ### 1. Image Requirements
51
+ - **MUST** provide ONE image to process
52
+ - **MUST** have clear subject in image
53
+ - **MUST** use reasonable resolution (min 512x512)
54
+ - **MUST** use supported formats (JPEG, PNG)
55
+ - **MUST NOT** exceed file size limits (10MB max)
114
56
 
115
- ```tsx
116
- interface RemoveBackgroundOptions {
117
- edgeSmoothness: 'low' | 'medium' | 'high';
118
- featherEdges?: boolean; // Soften edges for natural look
119
- preserveHair?: boolean; // Better hair detection (default: true)
120
- backgroundColor?: string; // Add new background color
121
- }
57
+ ### 2. Configuration
58
+ - **MUST** provide valid `userId` for tracking
59
+ - **MUST** specify `edgeSmoothness` (low, medium, high)
60
+ - **MUST** implement `onError` callback
61
+ - **MUST** implement `onSelectImage` callback
62
+ - **MUST** handle transparent PNG output
63
+
64
+ ### 3. State Management
65
+ - **MUST** check `isReady` before enabling remove button
66
+ - **MUST** display progress during processing
67
+ - **MUST** handle transparency display properly
68
+ - **MUST** display `error` state with clear messages
69
+ - **MUST** implement proper cleanup on unmount
70
+
71
+ ### 4. Performance
72
+ - **MUST** implement image compression before upload
73
+ - **MUST** show progress indicator for processing
74
+ - **MUST** cache results locally
75
+ - **MUST** handle large output images
76
+ - **MUST NOT** process multiple images simultaneously
77
+
78
+ ### 5. User Experience
79
+ - **MUST** show background preview with transparency grid
80
+ - **MUST** provide before/after comparison
81
+ - **MUST** offer edge smoothness options
82
+ - **MUST** handle complex subjects (hair, fur)
83
+ - **MUST** provide download as PNG
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 removal without user action
99
+ - Always require explicit "Remove Background" button press
100
+ - Provide clear preview before processing
101
+
102
+ 3. **No Hardcoded Credentials**
103
+ - Never store API keys in component files
104
+ - Use environment variables or secure storage
105
+
106
+ 4. **No Unhandled Errors**
107
+ - Never ignore detection failures
108
+ - Always explain what went wrong
109
+ - Provide retry or alternative options
110
+
111
+ 5. **No Memory Leaks**
112
+ - Never store large images unnecessarily
113
+ - Clean up temporary images
114
+ - Implement proper image disposal
115
+
116
+ 6. **No Blocking UI**
117
+ - Never block main thread with image processing
118
+ - Always show progress indicator
119
+ - Allow cancellation
120
+
121
+ 7. **No Poor Quality Output**
122
+ - Never compress PNG output excessively
123
+ - Preserve transparency quality
124
+ - Use appropriate edge settings
125
+
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 background removal 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 useRemoveBackgroundFeature hook
142
+ 3. Select edge smoothness level
143
+ 4. Implement image selection UI
144
+ 5. Validate image before processing
145
+ 6. Show before/after comparison with transparency
146
+ 7. Display result on transparency grid
147
+ 8. Implement proper error handling
148
+ 9. Provide PNG download
149
+ 10. Implement cleanup on unmount
150
+
151
+ CRITICAL RULES:
152
+ - MUST validate image before calling remove()
153
+ - MUST show before/after comparison
154
+ - MUST display transparency grid properly
155
+ - MUST handle complex subjects (hair, fur)
156
+ - MUST implement debouncing (300ms)
157
+ - MUST provide PNG format output
158
+
159
+ CONFIGURATION:
160
+ - Provide valid userId (string)
161
+ - Set edgeSmoothness: 'low' | 'medium' | 'high'
162
+ - Implement onSelectImage callback
163
+ - Implement onSaveImage callback
164
+ - Configure callbacks: onProcessingStart, onProcessingComplete, onError
165
+
166
+ OPTIONS:
167
+ - edgeSmoothness: 'low' | 'medium' | 'high'
168
+ - Low: Sharper edges, better for objects
169
+ - Medium: Balanced (recommended)
170
+ - High: Smoother edges, better for hair/fur
171
+
172
+ STRICTLY FORBIDDEN:
173
+ - No missing image validation
174
+ - No auto-processing without user action
175
+ - No hardcoded API keys
176
+ - No unhandled errors
177
+ - No memory leaks
178
+ - No blocking UI
179
+ - No poor quality PNG output
180
+
181
+ QUALITY CHECKLIST:
182
+ - [ ] Image selection implemented
183
+ - [ ] Edge smoothness selector
184
+ - [ ] Transparency grid display
185
+ - [ ] Before/after comparison view
186
+ - [ ] Progress indicator during processing
187
+ - [ ] Error display with retry option
188
+ - [ ] PNG download functionality
189
+ - [ ] Original image preserved
122
190
  ```
123
191
 
124
- ## Usage Flow
192
+ #### AI Implementation Checklist
125
193
 
126
- 1. Select **Image** - Choose an image with background to remove
127
- 2. Configure **Options** - Adjust edge smoothness and other settings
128
- 3. Tap **Remove Background** - Start the removal process
129
- 4. View **Result** - See the image with transparent background
130
- 5. Save or Edit - Save as PNG or add new background
194
+ Use this checklist when generating code:
131
195
 
132
- ## Component Examples
196
+ - [ ] Feature imported from correct path
197
+ - [ ] Image selection implemented
198
+ - [ ] Edge smoothness selector added
199
+ - [ ] Validation before remove()
200
+ - [ ] Transparency grid for result display
201
+ - [ ] Before/after comparison view
202
+ - [ ] Progress indicator during processing
203
+ - [ ] Error display with user-friendly message
204
+ - [ ] PNG download with transparency
205
+ - [ ] Cleanup on unmount
206
+ - [ ] Original image preserved
207
+ - [ ] Complex subject handling
133
208
 
134
- ### Edge Smoothness Selector
209
+ ---
135
210
 
136
- ```tsx
137
- import { GridSelector } from '@umituz/react-native-ai-generation-content';
211
+ ## 🛠️ Configuration Strategy
138
212
 
139
- const smoothnessOptions = [
140
- { id: 'low', name: 'Sharp', description: 'Precise edges' },
141
- { id: 'medium', name: 'Balanced', description: 'Natural edges' },
142
- { id: 'high', name: 'Smooth', description: 'Soft edges' },
143
- ];
213
+ ### Essential Configuration
144
214
 
145
- function MyScreen() {
146
- const [smoothness, setSmoothness] = useState('medium');
215
+ ```typescript
216
+ // Required fields
217
+ {
218
+ userId: string
219
+ edgeSmoothness: 'low' | 'medium' | 'high'
220
+ onSelectImage: () => Promise<string | null>
221
+ }
147
222
 
148
- return (
149
- <GridSelector
150
- options={smoothnessOptions}
151
- selectedOption={smoothness}
152
- onSelectOption={setSmoothness}
153
- />
154
- );
223
+ // Optional callbacks
224
+ {
225
+ onProcessingStart?: () => void
226
+ onProcessingComplete?: (result) => void
227
+ onError?: (error: string) => void
155
228
  }
156
229
  ```
157
230
 
158
- ### Background Preview
159
-
160
- ```tsx
161
- import { View, Image } from 'react-native';
162
-
163
- const previewBackgrounds = [
164
- { color: '#FFFFFF', name: 'White' },
165
- { color: '#000000', name: 'Black' },
166
- { color: '#F0F0F0', name: 'Gray' },
167
- { color: 'transparent', name: 'Transparent' },
168
- ];
169
-
170
- function BackgroundPreview({ imageUrl }) {
171
- const [background, setBackground] = useState('transparent');
172
-
173
- return (
174
- <View style={{ backgroundColor: background }}>
175
- <Image
176
- source={{ uri: imageUrl }}
177
- style={{ width: 300, height: 300 }}
178
- />
179
- </View>
180
- );
231
+ ### Recommended Settings
232
+
233
+ 1. **Edge Smoothness**
234
+ - Low: Sharp edges, best for simple objects
235
+ - Medium: Balanced (recommended for most cases)
236
+ - High: Smooth edges, best for hair, fur, complex subjects
237
+
238
+ 2. **Image Quality**
239
+ - Minimum: 512x512 resolution
240
+ - Recommended: 1024x1024 or higher
241
+ - Format: JPEG or PNG
242
+ - Max size: 10MB
243
+
244
+ 3. **Performance Settings**
245
+ - Compress images before upload
246
+ - Show progress for operations
247
+ - Implement timeout (60s default)
248
+ - Enable result caching
249
+
250
+ ---
251
+
252
+ ## 📊 State Management
253
+
254
+ ### Feature States
255
+
256
+ **isReady**: boolean
257
+ - Image selected and validated
258
+ - Check before enabling remove button
259
+
260
+ **isProcessing**: boolean
261
+ - Background removal in progress
262
+ - Show loading/progress indicator
263
+ - Disable remove button
264
+
265
+ **progress**: number (0-100)
266
+ - Processing progress percentage
267
+ - Update progress bar
268
+
269
+ **error**: string | null
270
+ - Error message if processing failed
271
+ - Display to user with clear message
272
+
273
+ **result**: {
274
+ imageUrl: string // Transparent PNG
275
+ originalImageUrl?: string
276
+ edgeSmoothness?: string
277
+ metadata?: any
181
278
  }
182
- ```
183
279
 
184
- ### Before/After Comparison
280
+ ---
185
281
 
186
- ```tsx
187
- import { ResultDisplay } from '@umituz/react-native-ai-generation-content';
282
+ ## 🎨 Best Practices
188
283
 
189
- {feature.state.result && image && (
190
- <ResultDisplay
191
- originalImage={image}
192
- resultImage={feature.state.result.imageUrl}
193
- onSave={() => feature.saveResult()}
194
- onShare={() => shareImage(feature.state.result.imageUrl)}
195
- />
196
- )}
197
- ```
284
+ ### Image Selection
198
285
 
199
- ## Advanced Usage
286
+ 1. **Subject Clarity**
287
+ - Good: Clear separation between subject and background
288
+ - Bad: Similar colors, low contrast between subject and background
200
289
 
201
- ### Custom Edge Smoothness
290
+ 2. **Lighting**
291
+ - Good: Even lighting on subject
292
+ - Bad: Harsh shadows, complex backgrounds
202
293
 
203
- ```tsx
204
- const result = await feature.process({
205
- edgeSmoothness: 'high',
206
- featherEdges: true,
207
- preserveHair: true,
208
- });
209
- ```
294
+ 3. **Edge Complexity**
295
+ - Simple objects: Use low edge smoothness
296
+ - Hair/fur: Use high edge smoothness
297
+ - Mixed: Use medium edge smoothness
210
298
 
211
- ### Add New Background
299
+ ### User Experience
212
300
 
213
- ```tsx
214
- // After removing background, add a new one
215
- const result = await feature.process({
216
- edgeSmoothness: 'medium',
217
- backgroundColor: '#FF5733', // Orange background
218
- });
219
- ```
301
+ 1. **Transparency Display**
302
+ - Show checkerboard pattern for transparency
303
+ - Allow background color preview
304
+ - Provide zoom for edge inspection
220
305
 
221
- ### Export with Mask
306
+ 2. **Comparison Tools**
307
+ - Before/after slider
308
+ - Toggle original/removed
309
+ - Edge detail zoom
222
310
 
223
- ```tsx
224
- const result = await feature.process({
225
- edgeSmoothness: 'medium',
226
- returnMask: true,
227
- });
311
+ 3. **Output Quality**
312
+ - Always provide PNG format
313
+ - Preserve edge quality
314
+ - Offer multiple resolution options
228
315
 
229
- // result.maskUrl contains the segmentation mask
230
- ```
316
+ ---
231
317
 
232
- ## Use Cases
318
+ ## 🐛 Common Pitfalls
233
319
 
234
- ### Product Photos
320
+ ### Detection Issues
235
321
 
236
- ```tsx
237
- // Remove background for e-commerce product photos
238
- const result = await feature.process({
239
- edgeSmoothness: 'high',
240
- preserveHair: false,
241
- });
242
- ```
322
+ ❌ **Problem**: Background not fully removed
323
+ **Solution**: Ensure good subject-background contrast, try different edge smoothness
243
324
 
244
- ### Profile Pictures
325
+ ### Edge Quality Issues
245
326
 
246
- ```tsx
247
- // Create clean profile pictures
248
- const result = await feature.process({
249
- edgeSmoothness: 'medium',
250
- featherEdges: true,
251
- });
252
- ```
327
+ ❌ **Problem**: Jagged or unnatural edges
328
+ **Solution**: Adjust edge smoothness, use higher setting for hair/fur
253
329
 
254
- ### Graphic Design
330
+ ### Transparency Issues
255
331
 
256
- ```tsx
257
- // Extract subjects for design work
258
- const result = await feature.process({
259
- edgeSmoothness: 'low',
260
- returnMask: true,
261
- });
262
- ```
332
+ ❌ **Problem**: Transparency not visible
333
+ **Solution**: Display with checkerboard pattern, offer background preview
263
334
 
264
- ## Best Practices
335
+ ### Performance Issues
265
336
 
266
- 1. **Image Quality**: Use high-resolution images for best results
267
- 2. **Subject Separation**: Ensure subject is clearly separated from background
268
- 3. **Edge Smoothness**: Adjust based on subject type (high for hair, low for objects)
269
- 4. **Hair/Fur**: Enable hair preservation for better results
270
- 5. **Lighting**: Even lighting produces better edge detection
337
+ **Problem**: Slow processing
338
+ **Solution**: Compress images, show progress, implement timeout
271
339
 
272
- ## Error Handling
340
+ ---
273
341
 
274
- ```tsx
275
- const { state, process } = useRemoveBackgroundFeature({ ...config });
342
+ ## 📦 Related Components
276
343
 
277
- useEffect(() => {
278
- if (state.error) {
279
- Alert.alert('Removal Failed', state.error);
280
- }
281
- }, [state.error]);
282
- ```
344
+ Use these components from the library:
345
+
346
+ - **PhotoUploadCard**: Upload image interface
347
+ - **ResultDisplay**: Before/after comparison
348
+ - **TransparencyGrid**: Display transparent images
349
+ - **EdgeSmoothnessSelector**: Choose edge quality
350
+ - **ProgressBar**: Progress display
351
+
352
+ Located at: `src/presentation/components/`
353
+
354
+ ---
355
+
356
+ ## 🔄 Migration Strategy
357
+
358
+ If migrating from previous implementation:
359
+
360
+ 1. **Update imports** to new path
361
+ 2. **Add edge smoothness selector**
362
+ 3. **Implement transparency grid display**
363
+ 4. **Update state handling** for new structure
364
+ 5. **Add before/after comparison**
365
+ 6. **Test with complex subjects**
366
+
367
+ ---
368
+
369
+ ## 📚 Additional Resources
370
+
371
+ - Main documentation: `/docs/`
372
+ - API reference: `/docs/api/`
373
+ - Examples: `/docs/examples/basic/remove-background/`
374
+ - Architecture: `/ARCHITECTURE.md`
375
+
376
+ ---
377
+
378
+ **Last Updated**: 2025-01-08
379
+ **Version**: 2.0.0 (Strategy-based Documentation)
283
380
 
284
- ## Related Features
381
+ ---
285
382
 
286
- - [Replace Background](../replace-background) - Replace with new background
287
- - [Remove Object](../remove-object) - Remove unwanted objects
288
- - [Image to Image](../image-to-image) - Transform images with AI
383
+ ## 📝 Changelog
289
384
 
290
- ## License
385
+ ### v2.0.0 - 2025-01-08
386
+ - **BREAKING**: Documentation format changed to strategy-based
387
+ - Removed extensive code examples
388
+ - Added rules, prohibitions, and AI agent directions
389
+ - Focus on best practices and implementation guidance
390
+ - Added transparency handling guidelines
291
391
 
292
- MIT
392
+ ### v1.0.0 - Initial Release
393
+ - Initial feature documentation