@umituz/react-native-ai-generation-content 1.89.36 → 1.89.37

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-generation-content",
3
- "version": "1.89.36",
3
+ "version": "1.89.37",
4
4
  "description": "Provider-agnostic AI generation orchestration for React Native with result preview components",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -2,117 +2,17 @@
2
2
  * Photo Extraction Utilities
3
3
  * Shared photo extraction logic for wizard strategies
4
4
  *
5
- * Resize strategy:
6
- * - Small images (<768px): scale UP to 768px minimum (good face preservation)
7
- * - Large images (>1536px): scale DOWN to 1536px maximum (reduces upload size ~10x)
8
- * - Normal images: pass through unchanged
5
+ * Extraction strategy:
6
+ * - Extract photo URIs from wizard data
7
+ * - Convert to base64 for AI generation
8
+ * - No resize or modification (original quality preserved)
9
9
  *
10
- * IMPORTANT: 768px minimum ensures AI models have enough detail for face preservation
10
+ * IMPORTANT: Uses original image quality. Users should provide high-quality images (512px+) for best results.
11
11
  */
12
12
 
13
13
  import { readFileAsBase64 } from "@umituz/react-native-design-system/filesystem";
14
- import { manipulateAsync, SaveFormat } from "expo-image-manipulator";
15
- import { Image } from "react-native";
16
14
  import { PHOTO_KEY_PREFIX } from "../wizard-strategy.constants";
17
15
 
18
-
19
- const MIN_IMAGE_DIMENSION = 768; // Minimum for good face preservation
20
- const MAX_IMAGE_DIMENSION = 1536;
21
-
22
- /**
23
- * Get image dimensions from URI
24
- */
25
- function getImageSize(uri: string): Promise<{ width: number; height: number }> {
26
- return new Promise((resolve, reject) => {
27
- Image.getSize(uri, (width, height) => resolve({ width, height }), reject);
28
- });
29
- }
30
-
31
- /**
32
- * Ensure image is within optimal dimensions for AI generation.
33
- * - Too small (<768px): scale up (good face preservation)
34
- * - Too large (>1536px): scale down (reduces upload size, prevents timeouts)
35
- * - Within range: return as-is
36
- */
37
- async function ensureOptimalSize(uri: string): Promise<string> {
38
- try {
39
- const { width, height } = await getImageSize(uri);
40
- const maxDim = Math.max(width, height);
41
-
42
- if (typeof __DEV__ !== "undefined" && __DEV__) {
43
- console.log("[PhotoExtraction] Analyzing image", {
44
- originalDimensions: `${width}x${height}`,
45
- maxDim,
46
- minDim: Math.min(width, height),
47
- isTooSmall: width < MIN_IMAGE_DIMENSION || height < MIN_IMAGE_DIMENSION,
48
- isTooLarge: maxDim > MAX_IMAGE_DIMENSION,
49
- });
50
- }
51
-
52
- // Already within optimal range
53
- if (width >= MIN_IMAGE_DIMENSION && height >= MIN_IMAGE_DIMENSION && maxDim <= MAX_IMAGE_DIMENSION) {
54
- if (typeof __DEV__ !== "undefined" && __DEV__) {
55
- console.log("[PhotoExtraction] Image already optimal, skipping resize", {
56
- dimensions: `${width}x${height}`,
57
- minRequired: MIN_IMAGE_DIMENSION,
58
- maxAllowed: MAX_IMAGE_DIMENSION,
59
- });
60
- }
61
- return uri;
62
- }
63
-
64
- let newWidth: number;
65
- let newHeight: number;
66
- let direction: string;
67
-
68
- if (maxDim > MAX_IMAGE_DIMENSION) {
69
- // Scale DOWN — largest dimension becomes MAX_IMAGE_DIMENSION
70
- const scale = MAX_IMAGE_DIMENSION / maxDim;
71
- newWidth = Math.round(width * scale);
72
- newHeight = Math.round(height * scale);
73
- direction = "down";
74
- } else {
75
- // Scale UP — smallest dimension becomes MIN_IMAGE_DIMENSION
76
- const scale = Math.max(MIN_IMAGE_DIMENSION / width, MIN_IMAGE_DIMENSION / height);
77
- newWidth = Math.ceil(width * scale);
78
- newHeight = Math.ceil(height * scale);
79
- direction = "up";
80
- }
81
-
82
- const compressQuality = maxDim > MAX_IMAGE_DIMENSION ? 0.8 : 1.0; // Lossless for scale-up
83
-
84
- if (typeof __DEV__ !== "undefined" && __DEV__) {
85
- console.log(`[PhotoExtraction] Resizing ${direction}`, {
86
- from: `${width}x${height}`,
87
- to: `${newWidth}x${newHeight}`,
88
- scaleChange: `${((Math.max(newWidth, newHeight) / maxDim - 1) * 100).toFixed(0)}%`,
89
- compressQuality,
90
- });
91
- }
92
-
93
- const result = await manipulateAsync(uri, [{ resize: { width: newWidth, height: newHeight } }], {
94
- format: SaveFormat.JPEG,
95
- compress: compressQuality,
96
- });
97
-
98
- if (typeof __DEV__ !== "undefined" && __DEV__) {
99
- console.log("[PhotoExtraction] Resize complete", {
100
- original: `${width}x${height}`,
101
- resized: `${newWidth}x${newHeight}`,
102
- action: direction,
103
- quality: compressQuality === 1.0 ? "lossless" : `${compressQuality * 100}%`,
104
- });
105
- }
106
-
107
- return result.uri;
108
- } catch (error) {
109
- if (typeof __DEV__ !== "undefined" && __DEV__) {
110
- console.error("[PhotoExtraction] Resize failed, using original", error);
111
- }
112
- return uri;
113
- }
114
- }
115
-
116
16
  /**
117
17
  * Extracts photo URIs from wizard data
118
18
  * Exported for use in other strategies (e.g., couple refinement)
@@ -140,6 +40,9 @@ export function extractPhotoUris(wizardData: Record<string, unknown>): string[]
140
40
  /**
141
41
  * Extracts and converts photos to base64 from wizard data
142
42
  * Used by both image and video strategies
43
+ *
44
+ * Note: This function preserves original image quality. No resize or modification is applied.
45
+ * For best AI generation results, users should provide high-quality images (512px+ recommended).
143
46
  */
144
47
  export async function extractPhotosAsBase64(
145
48
  wizardData: Record<string, unknown>,
@@ -149,8 +52,6 @@ export async function extractPhotosAsBase64(
149
52
  console.log("[PhotoExtraction] >>> extractPhotosAsBase64 START", {
150
53
  wizardDataKeys: Object.keys(wizardData),
151
54
  photoKeyPrefix: PHOTO_KEY_PREFIX,
152
- minDimension: MIN_IMAGE_DIMENSION,
153
- maxDimension: MAX_IMAGE_DIMENSION,
154
55
  });
155
56
  }
156
57
 
@@ -180,8 +81,8 @@ export async function extractPhotosAsBase64(
180
81
  });
181
82
  }
182
83
 
183
- const optimizedUri = await ensureOptimalSize(uri);
184
- const base64 = await readFileAsBase64(optimizedUri);
84
+ // Direct base64 conversion - no resize or modification
85
+ const base64 = await readFileAsBase64(uri);
185
86
 
186
87
  if (enableDebugLogs && typeof __DEV__ !== "undefined" && __DEV__) {
187
88
  console.log(`[PhotoExtraction] Photo ${index + 1} processed`, {