@umituz/react-native-image 1.3.8 → 1.3.10

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 (23) hide show
  1. package/package.json +8 -2
  2. package/src/index.ts +5 -4
  3. package/src/infrastructure/services/ImageConversionService.ts +7 -32
  4. package/src/infrastructure/services/ImageEditorService.ts +41 -179
  5. package/src/infrastructure/services/{ImageAIEnhancementService.ts → ImageEnhanceService.ts} +42 -55
  6. package/src/infrastructure/services/ImageTemplateService.ts +10 -4
  7. package/src/infrastructure/services/ImageTransformService.ts +43 -93
  8. package/src/infrastructure/utils/FilterProcessor.ts +26 -263
  9. package/src/infrastructure/utils/{AIImageAnalysisUtils.ts → ImageAnalysisUtils.ts} +3 -3
  10. package/src/infrastructure/utils/ImageEditorHistoryUtils.ts +63 -0
  11. package/src/infrastructure/utils/ImageFilterUtils.ts +152 -0
  12. package/src/infrastructure/utils/ImageTransformUtils.ts +25 -0
  13. package/src/infrastructure/utils/LayerManager.ts +0 -81
  14. package/src/presentation/components/editor/FilterPickerSheet.tsx +75 -0
  15. package/src/presentation/components/editor/StickerPickerSheet.tsx +62 -0
  16. package/src/presentation/components/editor/TextEditorSheet.tsx +98 -0
  17. package/src/presentation/components/editor/TextEditorTabs.tsx +111 -0
  18. package/src/presentation/hooks/useImage.ts +5 -8
  19. package/src/presentation/hooks/useImageEnhance.ts +32 -0
  20. package/src/presentation/hooks/useImageTransform.ts +3 -4
  21. package/src/infrastructure/services/ImageAdvancedTransformService.ts +0 -106
  22. package/src/infrastructure/services/ImageSpecializedEnhancementService.ts +0 -57
  23. package/src/presentation/hooks/useImageAIEnhancement.ts +0 -33
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Presentation - Image Enhance Hook
3
+ */
4
+
5
+ import { useCallback } from 'react';
6
+ import { useImageOperation } from './useImageOperation';
7
+ import { ImageEnhanceService, type AutoEnhancementOptions } from '../../infrastructure/services/ImageEnhanceService';
8
+
9
+ export const useImageEnhance = () => {
10
+ const { isProcessing, error, execute } = useImageOperation();
11
+
12
+ const autoEnhance = useCallback((uri: string, options?: AutoEnhancementOptions) =>
13
+ execute(() => ImageEnhanceService.autoEnhance(uri, options), 'Failed to auto enhance'), [execute]);
14
+
15
+ const enhancePortrait = useCallback((uri: string) =>
16
+ execute(() => ImageEnhanceService.enhancePortrait(uri), 'Failed to enhance portrait'), [execute]);
17
+
18
+ const enhanceLandscape = useCallback((uri: string) =>
19
+ execute(() => ImageEnhanceService.enhanceLandscape(uri), 'Failed to enhance landscape'), [execute]);
20
+
21
+ const analyzeImage = useCallback((uri: string) =>
22
+ execute(() => ImageEnhanceService.analyzeImage(uri), 'Failed to analyze image'), [execute]);
23
+
24
+ return {
25
+ autoEnhance,
26
+ enhancePortrait,
27
+ enhanceLandscape,
28
+ analyzeImage,
29
+ isEnhancing: isProcessing,
30
+ enhancementError: error,
31
+ };
32
+ };
@@ -4,7 +4,6 @@
4
4
  import { useCallback } from 'react';
5
5
  import { useImageOperation } from './useImageOperation';
6
6
  import { ImageTransformService } from '../../infrastructure/services/ImageTransformService';
7
- import { ImageAdvancedTransformService } from '../../infrastructure/services/ImageAdvancedTransformService';
8
7
  import type {
9
8
  ImageManipulateAction,
10
9
  ImageSaveOptions,
@@ -28,13 +27,13 @@ export const useImageTransform = () => {
28
27
  execute(() => ImageTransformService.flip(uri, flipParams, options), 'Failed to flip'), [execute]);
29
28
 
30
29
  const manipulate = useCallback((uri: string, action: ImageManipulateAction, options?: ImageSaveOptions) =>
31
- execute(() => ImageAdvancedTransformService.manipulate(uri, action, options), 'Failed to manipulate'), [execute]);
30
+ execute(() => ImageTransformService.manipulate(uri, action, options), 'Failed to manipulate'), [execute]);
32
31
 
33
32
  const resizeToFit = useCallback((uri: string, maxWidth: number, maxHeight: number, options?: ImageSaveOptions) =>
34
- execute(() => ImageAdvancedTransformService.resizeToFit(uri, maxWidth, maxHeight, options), 'Failed to resize to fit'), [execute]);
33
+ execute(() => ImageTransformService.resizeToFit(uri, maxWidth, maxHeight, options), 'Failed to resize to fit'), [execute]);
35
34
 
36
35
  const cropToSquare = useCallback((uri: string, width: number, height: number, options?: ImageSaveOptions) =>
37
- execute(() => ImageAdvancedTransformService.cropToSquare(uri, width, height, options), 'Failed to crop square'), [execute]);
36
+ execute(() => ImageTransformService.cropToSquare(uri, width, height, options), 'Failed to crop square'), [execute]);
38
37
 
39
38
  return {
40
39
  resize, crop, rotate, flip, manipulate, resizeToFit, cropToSquare,
@@ -1,106 +0,0 @@
1
- /**
2
- * Image Infrastructure - Advanced Transform Service
3
- */
4
-
5
- import * as ImageManipulator from 'expo-image-manipulator';
6
- import type {
7
- ImageManipulateAction,
8
- ImageSaveOptions,
9
- ImageManipulationResult,
10
- } from '../../domain/entities/ImageTypes';
11
- import { ImageTransformService } from './ImageTransformService';
12
- import { ImageUtils } from '../../domain/utils/ImageUtils';
13
- import { ImageValidator } from '../utils/ImageValidator';
14
- import { ImageErrorHandler, IMAGE_ERROR_CODES } from '../utils/ImageErrorHandler';
15
-
16
- export class ImageAdvancedTransformService {
17
- static async manipulate(
18
- uri: string,
19
- action: ImageManipulateAction,
20
- options?: ImageSaveOptions
21
- ): Promise<ImageManipulationResult> {
22
- try {
23
- const uriValidation = ImageValidator.validateUri(uri);
24
- if (!uriValidation.isValid) {
25
- throw ImageErrorHandler.createError(uriValidation.error!, IMAGE_ERROR_CODES.INVALID_URI, 'manipulate');
26
- }
27
-
28
- const actions: ImageManipulator.Action[] = [];
29
-
30
- if (action.resize) {
31
- const dimValidation = ImageValidator.validateDimensions(action.resize);
32
- if (!dimValidation.isValid) {
33
- throw ImageErrorHandler.createError(dimValidation.error!, IMAGE_ERROR_CODES.INVALID_DIMENSIONS, 'manipulate');
34
- }
35
- actions.push({ resize: action.resize });
36
- }
37
-
38
- if (action.crop) {
39
- const dimValidation = ImageValidator.validateDimensions(action.crop);
40
- if (!dimValidation.isValid) {
41
- throw ImageErrorHandler.createError(dimValidation.error!, IMAGE_ERROR_CODES.INVALID_DIMENSIONS, 'manipulate');
42
- }
43
- actions.push({ crop: action.crop });
44
- }
45
-
46
- if (action.rotate) {
47
- const rotationValidation = ImageValidator.validateRotation(action.rotate);
48
- if (!rotationValidation.isValid) {
49
- throw ImageErrorHandler.createError(rotationValidation.error!, IMAGE_ERROR_CODES.VALIDATION_ERROR, 'manipulate');
50
- }
51
- actions.push({ rotate: action.rotate });
52
- }
53
-
54
- if (action.flip) {
55
- if (action.flip.horizontal) actions.push({ flip: ImageManipulator.FlipType.Horizontal });
56
- if (action.flip.vertical) actions.push({ flip: ImageManipulator.FlipType.Vertical });
57
- }
58
-
59
- return await ImageManipulator.manipulateAsync(
60
- uri,
61
- actions,
62
- ImageTransformService['buildSaveOptions'](options)
63
- );
64
- } catch (error) {
65
- throw ImageErrorHandler.handleUnknownError(error, 'manipulate');
66
- }
67
- }
68
-
69
- static async resizeToFit(
70
- uri: string,
71
- maxWidth: number,
72
- maxHeight: number,
73
- options?: ImageSaveOptions
74
- ): Promise<ImageManipulationResult> {
75
- try {
76
- const dimValidation = ImageValidator.validateDimensions({ width: maxWidth, height: maxHeight });
77
- if (!dimValidation.isValid) {
78
- throw ImageErrorHandler.createError(dimValidation.error!, IMAGE_ERROR_CODES.INVALID_DIMENSIONS, 'resizeToFit');
79
- }
80
-
81
- const dimensions = ImageUtils.fitToSize(maxWidth, maxHeight, maxWidth, maxHeight);
82
- return ImageTransformService.resize(uri, dimensions.width, dimensions.height, options);
83
- } catch (error) {
84
- throw ImageErrorHandler.handleUnknownError(error, 'resizeToFit');
85
- }
86
- }
87
-
88
- static async cropToSquare(
89
- uri: string,
90
- width: number,
91
- height: number,
92
- options?: ImageSaveOptions
93
- ): Promise<ImageManipulationResult> {
94
- try {
95
- const dimValidation = ImageValidator.validateDimensions({ width, height });
96
- if (!dimValidation.isValid) {
97
- throw ImageErrorHandler.createError(dimValidation.error!, IMAGE_ERROR_CODES.INVALID_DIMENSIONS, 'cropToSquare');
98
- }
99
-
100
- const cropArea = ImageUtils.getSquareCrop(width, height);
101
- return ImageTransformService.crop(uri, cropArea, options);
102
- } catch (error) {
103
- throw ImageErrorHandler.handleUnknownError(error, 'cropToSquare');
104
- }
105
- }
106
- }
@@ -1,57 +0,0 @@
1
- /**
2
- * Image Infrastructure - Specialized Enhancement
3
- *
4
- * Portrait and landscape specific enhancement services
5
- */
6
-
7
- import type { ImageManipulationResult } from '../../domain/entities/ImageTypes';
8
- import { ImageValidator } from '../utils/ImageValidator';
9
- import { ImageErrorHandler, IMAGE_ERROR_CODES } from '../utils/ImageErrorHandler';
10
-
11
- export class ImageSpecializedEnhancementService {
12
- static async enhancePortrait(uri: string): Promise<ImageManipulationResult> {
13
- try {
14
- const uriValidation = ImageValidator.validateUri(uri);
15
- if (!uriValidation.isValid) {
16
- throw ImageErrorHandler.createError(uriValidation.error!, IMAGE_ERROR_CODES.INVALID_URI, 'enhancePortrait');
17
- }
18
-
19
- // Portrait-specific enhancements:
20
- // - Skin smoothing
21
- // - Eye enhancement
22
- // - Face detection and lighting adjustment
23
- // - Background blur (bokeh effect)
24
-
25
- return {
26
- uri,
27
- width: 0,
28
- height: 0,
29
- };
30
- } catch (error) {
31
- throw ImageErrorHandler.handleUnknownError(error, 'enhancePortrait');
32
- }
33
- }
34
-
35
- static async enhanceLandscape(uri: string): Promise<ImageManipulationResult> {
36
- try {
37
- const uriValidation = ImageValidator.validateUri(uri);
38
- if (!uriValidation.isValid) {
39
- throw ImageErrorHandler.createError(uriValidation.error!, IMAGE_ERROR_CODES.INVALID_URI, 'enhanceLandscape');
40
- }
41
-
42
- // Landscape-specific enhancements:
43
- // - Sky enhancement
44
- // - Green tone adjustment
45
- // - HDR effect simulation
46
- // - Perspective correction
47
-
48
- return {
49
- uri,
50
- width: 0,
51
- height: 0,
52
- };
53
- } catch (error) {
54
- throw ImageErrorHandler.handleUnknownError(error, 'enhanceLandscape');
55
- }
56
- }
57
- }
@@ -1,33 +0,0 @@
1
- /**
2
- * Presentation - Image AI Enhancement Hook
3
- */
4
-
5
- import { useCallback } from 'react';
6
- import { useImageOperation } from './useImageOperation';
7
- import { ImageAIEnhancementService, type AutoEnhancementOptions, type EnhancementResult } from '../../infrastructure/services/ImageAIEnhancementService';
8
- import { ImageSpecializedEnhancementService } from '../../infrastructure/services/ImageSpecializedEnhancementService';
9
-
10
- export const useImageAIEnhancement = () => {
11
- const { isProcessing, error, execute } = useImageOperation();
12
-
13
- const autoEnhance = useCallback((uri: string, options?: AutoEnhancementOptions) =>
14
- execute(() => ImageAIEnhancementService.autoEnhance(uri, options), 'Failed to auto enhance'), [execute]);
15
-
16
- const enhancePortrait = useCallback((uri: string) =>
17
- execute(() => ImageSpecializedEnhancementService.enhancePortrait(uri), 'Failed to enhance portrait'), [execute]);
18
-
19
- const enhanceLandscape = useCallback((uri: string) =>
20
- execute(() => ImageSpecializedEnhancementService.enhanceLandscape(uri), 'Failed to enhance landscape'), [execute]);
21
-
22
- const analyzeImage = useCallback((uri: string) =>
23
- execute(() => ImageAIEnhancementService.analyzeImage(uri), 'Failed to analyze image'), [execute]);
24
-
25
- return {
26
- autoEnhance,
27
- enhancePortrait,
28
- enhanceLandscape,
29
- analyzeImage,
30
- isEnhancing: isProcessing,
31
- enhancementError: error,
32
- };
33
- };