@umituz/react-native-image 1.3.4 → 1.3.6
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-image",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.6",
|
|
4
4
|
"description": "Image manipulation and viewing for React Native apps - resize, crop, rotate, flip, compress, gallery viewer",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
package/src/index.ts
CHANGED
|
@@ -26,6 +26,11 @@ export type {
|
|
|
26
26
|
ImageFlipOptions,
|
|
27
27
|
} from './domain/entities/ImageTypes';
|
|
28
28
|
|
|
29
|
+
export type {
|
|
30
|
+
ImageTemplate,
|
|
31
|
+
MemeTemplateOptions,
|
|
32
|
+
} from './domain/entities/ImageTemplateTypes';
|
|
33
|
+
|
|
29
34
|
export {
|
|
30
35
|
ImageFormat,
|
|
31
36
|
ImageOrientation,
|
|
@@ -68,6 +73,7 @@ export { ImageAIEnhancementService, type AutoEnhancementOptions, type Enhancemen
|
|
|
68
73
|
export { ImageMetadataService, type ImageMetadataExtractionOptions } from './infrastructure/services/ImageMetadataService';
|
|
69
74
|
export { ImageQualityPresetService, type QualityPreset, type QualityPresets, IMAGE_QUALITY_PRESETS } from './infrastructure/utils/ImageQualityPresets';
|
|
70
75
|
export { ImageSpecializedEnhancementService } from './infrastructure/services/ImageSpecializedEnhancementService';
|
|
76
|
+
export { ImageTemplateService } from './infrastructure/services/ImageTemplateService';
|
|
71
77
|
|
|
72
78
|
// =============================================================================
|
|
73
79
|
// PRESENTATION LAYER - React Native Components & Hooks
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { MemeTemplateOptions } from '../../domain/entities/ImageTemplateTypes';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ImageTemplateService
|
|
5
|
+
*
|
|
6
|
+
* Provides utilities for generating image template URLs (e.g. Memegen.link)
|
|
7
|
+
*/
|
|
8
|
+
export class ImageTemplateService {
|
|
9
|
+
/**
|
|
10
|
+
* Generates a Memegen.link URL for a given template and texts
|
|
11
|
+
*
|
|
12
|
+
* @param options Meme configuration (templateKey, topText, bottomText)
|
|
13
|
+
* @returns Formatted memegen.link URL
|
|
14
|
+
*/
|
|
15
|
+
static generateMemeUrl(options: MemeTemplateOptions): string {
|
|
16
|
+
const { templateKey, topText = '', bottomText = '' } = options;
|
|
17
|
+
|
|
18
|
+
// Internal helper for memegen-specific encoding
|
|
19
|
+
const encodeMemeText = (text: string) => {
|
|
20
|
+
const sanitized = text.trim();
|
|
21
|
+
if (!sanitized) return "_";
|
|
22
|
+
|
|
23
|
+
return encodeURIComponent(
|
|
24
|
+
sanitized
|
|
25
|
+
.replace(/ /g, "_")
|
|
26
|
+
.replace(/\?/g, "~q")
|
|
27
|
+
.replace(/#/g, "~h")
|
|
28
|
+
.replace(/\//g, "~s")
|
|
29
|
+
// Additional memegen.link requirements if needed
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const top = encodeMemeText(topText);
|
|
34
|
+
const bottom = encodeMemeText(bottomText);
|
|
35
|
+
|
|
36
|
+
return `https://api.memegen.link/images/${templateKey}/${top}/${bottom}.png`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Extracts template key from a memegen.link URL or filename
|
|
41
|
+
*/
|
|
42
|
+
static extractTemplateKey(url: string): string {
|
|
43
|
+
if (!url) return 'custom';
|
|
44
|
+
|
|
45
|
+
// Example: https://api.memegen.link/images/distracted.png -> distracted
|
|
46
|
+
const parts = url.split('/');
|
|
47
|
+
const lastPart = parts[parts.length - 1] || '';
|
|
48
|
+
return lastPart.split('.')[0] || 'custom';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
import { useCallback } from 'react';
|
|
6
6
|
import { useImageOperation } from './useImageOperation';
|
|
7
7
|
import { ImageBatchService, type BatchOperation, type BatchProcessingOptions } from '../../infrastructure/services/ImageBatchService';
|
|
8
|
-
import type { ImageFilter } from '../../domain/entities/ImageFilterTypes';
|
|
9
8
|
|
|
10
9
|
export const useImageBatch = () => {
|
|
11
10
|
const { isProcessing, error, execute } = useImageOperation();
|
|
@@ -19,14 +18,10 @@ export const useImageBatch = () => {
|
|
|
19
18
|
const compressBatch = useCallback((uris: string[], quality?: number, options?: BatchProcessingOptions) =>
|
|
20
19
|
execute(() => ImageBatchService.compressBatch(uris, quality, options), 'Failed to compress batch'), [execute]);
|
|
21
20
|
|
|
22
|
-
const filterBatch = useCallback((uris: string[], filter: ImageFilter, options?: BatchProcessingOptions) =>
|
|
23
|
-
execute(() => ImageBatchService.filterBatch(uris, filter, options), 'Failed to filter batch'), [execute]);
|
|
24
|
-
|
|
25
21
|
return {
|
|
26
22
|
processBatch,
|
|
27
23
|
resizeBatch,
|
|
28
24
|
compressBatch,
|
|
29
|
-
filterBatch,
|
|
30
25
|
isBatchProcessing: isProcessing,
|
|
31
26
|
batchError: error,
|
|
32
27
|
};
|