react-native-rectangle-doc-scanner 3.99.0 → 3.100.0
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/dist/FullDocScanner.js +34 -49
- package/package.json +2 -5
- package/src/FullDocScanner.tsx +39 -60
- package/src/types/react-native-image-rotate.d.ts +0 -10
package/dist/FullDocScanner.js
CHANGED
|
@@ -41,7 +41,6 @@ const react_1 = __importStar(require("react"));
|
|
|
41
41
|
const react_native_1 = require("react-native");
|
|
42
42
|
const react_native_image_picker_1 = require("react-native-image-picker");
|
|
43
43
|
const react_native_image_crop_picker_1 = __importDefault(require("react-native-image-crop-picker"));
|
|
44
|
-
const react_native_image_rotate_1 = __importDefault(require("react-native-image-rotate"));
|
|
45
44
|
const react_native_fs_1 = __importDefault(require("react-native-fs"));
|
|
46
45
|
const DocScanner_1 = require("./DocScanner");
|
|
47
46
|
const stripFileUri = (value) => value.replace(/^file:\/\//, '');
|
|
@@ -347,62 +346,48 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
|
|
|
347
346
|
const handleRotateImage = (0, react_1.useCallback)(async (degrees) => {
|
|
348
347
|
if (!croppedImageData)
|
|
349
348
|
return;
|
|
350
|
-
// UI 회전 상태 먼저 업데이트 (즉각 반응)
|
|
351
|
-
setRotationDegrees(prev => {
|
|
352
|
-
const newRotation = (prev + degrees + 360) % 360;
|
|
353
|
-
return newRotation;
|
|
354
|
-
});
|
|
355
349
|
console.log('[FullDocScanner] Starting image rotation...', {
|
|
356
350
|
path: croppedImageData.path,
|
|
357
351
|
hasBase64: !!croppedImageData.base64,
|
|
352
|
+
base64Length: croppedImageData.base64?.length,
|
|
358
353
|
});
|
|
359
354
|
try {
|
|
360
|
-
//
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
});
|
|
380
|
-
console.log('[FullDocScanner] Rotated image saved with base64');
|
|
381
|
-
// 회전된 이미지로 교체
|
|
382
|
-
setCroppedImageData({
|
|
383
|
-
path: savedImage.path,
|
|
384
|
-
base64: savedImage.data ?? undefined,
|
|
385
|
-
});
|
|
386
|
-
// rotation degrees는 0으로 리셋
|
|
387
|
-
setRotationDegrees(0);
|
|
388
|
-
}
|
|
389
|
-
catch (cropError) {
|
|
390
|
-
console.error('[FullDocScanner] Failed to save rotated image:', cropError);
|
|
391
|
-
// 사용자가 취소한 경우 rotation 원복
|
|
392
|
-
setRotationDegrees(prev => (prev - degrees + 360) % 360);
|
|
393
|
-
}
|
|
394
|
-
}, (error) => {
|
|
395
|
-
console.error('[FullDocScanner] Image rotation error:', error);
|
|
396
|
-
// 에러 발생 시 UI rotation 원복
|
|
397
|
-
setRotationDegrees(prev => {
|
|
398
|
-
const revertRotation = (prev - degrees + 360) % 360;
|
|
399
|
-
return revertRotation;
|
|
400
|
-
});
|
|
355
|
+
// 원본 파일을 ImageCropPicker로 열어서 회전 적용
|
|
356
|
+
// 사용자가 수동으로 회전 버튼을 클릭하고 완료를 눌러야 함
|
|
357
|
+
const rotatedImage = await react_native_image_crop_picker_1.default.openCropper({
|
|
358
|
+
path: croppedImageData.path,
|
|
359
|
+
mediaType: 'photo',
|
|
360
|
+
cropping: true,
|
|
361
|
+
freeStyleCropEnabled: true,
|
|
362
|
+
includeBase64: true,
|
|
363
|
+
compressImageQuality: 0.9,
|
|
364
|
+
cropperToolbarTitle: degrees === 90 ? '우측 90° 회전 → 회전 버튼 클릭 → 완료' : '좌측 90° 회전 → 회전 버튼 클릭 → 완료',
|
|
365
|
+
cropperChooseText: '완료',
|
|
366
|
+
cropperCancelText: '취소',
|
|
367
|
+
cropperRotateButtonsHidden: false,
|
|
368
|
+
enableRotationGesture: true,
|
|
369
|
+
});
|
|
370
|
+
console.log('[FullDocScanner] Rotated image saved:', {
|
|
371
|
+
path: rotatedImage.path,
|
|
372
|
+
hasBase64: !!rotatedImage.data,
|
|
373
|
+
base64Length: rotatedImage.data?.length,
|
|
401
374
|
});
|
|
375
|
+
// 회전된 이미지로 교체
|
|
376
|
+
setCroppedImageData({
|
|
377
|
+
path: rotatedImage.path,
|
|
378
|
+
base64: rotatedImage.data ?? undefined,
|
|
379
|
+
});
|
|
380
|
+
// rotation degrees는 0으로 리셋
|
|
381
|
+
setRotationDegrees(0);
|
|
402
382
|
}
|
|
403
383
|
catch (error) {
|
|
404
|
-
console.error('[FullDocScanner]
|
|
405
|
-
|
|
384
|
+
console.error('[FullDocScanner] Image rotation error:', error);
|
|
385
|
+
// 사용자가 취소했으면 아무것도 안함
|
|
386
|
+
const errorMessage = error && typeof error === 'object' && 'message' in error ? error.message : '';
|
|
387
|
+
if (!errorMessage.includes('cancel') && !errorMessage.includes('User cancelled')) {
|
|
388
|
+
// 에러 메시지 표시
|
|
389
|
+
react_native_1.Alert.alert('회전 실패', '이미지 회전 중 오류가 발생했습니다.');
|
|
390
|
+
}
|
|
406
391
|
}
|
|
407
392
|
}, [croppedImageData]);
|
|
408
393
|
const handleConfirm = (0, react_1.useCallback)(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-rectangle-doc-scanner",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.100.0",
|
|
4
4
|
"description": "Native-backed document scanner for React Native with customizable overlays.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
"react-native-fs": "*",
|
|
37
37
|
"react-native-image-crop-picker": "*",
|
|
38
38
|
"react-native-image-picker": "*",
|
|
39
|
-
"react-native-image-rotate": "*",
|
|
40
39
|
"react-native-svg": "*"
|
|
41
40
|
},
|
|
42
41
|
"devDependencies": {
|
|
@@ -47,7 +46,5 @@
|
|
|
47
46
|
"react-native-image-picker": "^7.1.2",
|
|
48
47
|
"typescript": "^5.3.3"
|
|
49
48
|
},
|
|
50
|
-
"dependencies": {
|
|
51
|
-
"react-native-image-rotate": "*"
|
|
52
|
-
}
|
|
49
|
+
"dependencies": {}
|
|
53
50
|
}
|
package/src/FullDocScanner.tsx
CHANGED
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
} from 'react-native';
|
|
12
12
|
import { launchImageLibrary } from 'react-native-image-picker';
|
|
13
13
|
import ImageCropPicker from 'react-native-image-crop-picker';
|
|
14
|
-
import ImageRotate from 'react-native-image-rotate';
|
|
15
14
|
import RNFS from 'react-native-fs';
|
|
16
15
|
import { DocScanner } from './DocScanner';
|
|
17
16
|
import type { CapturedDocument } from './types';
|
|
@@ -459,72 +458,52 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
|
|
|
459
458
|
const handleRotateImage = useCallback(async (degrees: -90 | 90) => {
|
|
460
459
|
if (!croppedImageData) return;
|
|
461
460
|
|
|
462
|
-
// UI 회전 상태 먼저 업데이트 (즉각 반응)
|
|
463
|
-
setRotationDegrees(prev => {
|
|
464
|
-
const newRotation = (prev + degrees + 360) % 360;
|
|
465
|
-
return newRotation;
|
|
466
|
-
});
|
|
467
|
-
|
|
468
461
|
console.log('[FullDocScanner] Starting image rotation...', {
|
|
469
462
|
path: croppedImageData.path,
|
|
470
463
|
hasBase64: !!croppedImageData.base64,
|
|
464
|
+
base64Length: croppedImageData.base64?.length,
|
|
471
465
|
});
|
|
472
466
|
|
|
473
467
|
try {
|
|
474
|
-
//
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
path: savedImage.path,
|
|
505
|
-
base64: savedImage.data ?? undefined,
|
|
506
|
-
});
|
|
507
|
-
|
|
508
|
-
// rotation degrees는 0으로 리셋
|
|
509
|
-
setRotationDegrees(0);
|
|
510
|
-
} catch (cropError) {
|
|
511
|
-
console.error('[FullDocScanner] Failed to save rotated image:', cropError);
|
|
512
|
-
// 사용자가 취소한 경우 rotation 원복
|
|
513
|
-
setRotationDegrees(prev => (prev - degrees + 360) % 360);
|
|
514
|
-
}
|
|
515
|
-
},
|
|
516
|
-
(error: Error) => {
|
|
517
|
-
console.error('[FullDocScanner] Image rotation error:', error);
|
|
518
|
-
// 에러 발생 시 UI rotation 원복
|
|
519
|
-
setRotationDegrees(prev => {
|
|
520
|
-
const revertRotation = (prev - degrees + 360) % 360;
|
|
521
|
-
return revertRotation;
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
|
-
);
|
|
468
|
+
// 원본 파일을 ImageCropPicker로 열어서 회전 적용
|
|
469
|
+
// 사용자가 수동으로 회전 버튼을 클릭하고 완료를 눌러야 함
|
|
470
|
+
const rotatedImage = await ImageCropPicker.openCropper({
|
|
471
|
+
path: croppedImageData.path,
|
|
472
|
+
mediaType: 'photo',
|
|
473
|
+
cropping: true,
|
|
474
|
+
freeStyleCropEnabled: true,
|
|
475
|
+
includeBase64: true,
|
|
476
|
+
compressImageQuality: 0.9,
|
|
477
|
+
cropperToolbarTitle: degrees === 90 ? '우측 90° 회전 → 회전 버튼 클릭 → 완료' : '좌측 90° 회전 → 회전 버튼 클릭 → 완료',
|
|
478
|
+
cropperChooseText: '완료',
|
|
479
|
+
cropperCancelText: '취소',
|
|
480
|
+
cropperRotateButtonsHidden: false,
|
|
481
|
+
enableRotationGesture: true,
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
console.log('[FullDocScanner] Rotated image saved:', {
|
|
485
|
+
path: rotatedImage.path,
|
|
486
|
+
hasBase64: !!rotatedImage.data,
|
|
487
|
+
base64Length: rotatedImage.data?.length,
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
// 회전된 이미지로 교체
|
|
491
|
+
setCroppedImageData({
|
|
492
|
+
path: rotatedImage.path,
|
|
493
|
+
base64: rotatedImage.data ?? undefined,
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
// rotation degrees는 0으로 리셋
|
|
497
|
+
setRotationDegrees(0);
|
|
525
498
|
} catch (error) {
|
|
526
|
-
console.error('[FullDocScanner]
|
|
527
|
-
|
|
499
|
+
console.error('[FullDocScanner] Image rotation error:', error);
|
|
500
|
+
|
|
501
|
+
// 사용자가 취소했으면 아무것도 안함
|
|
502
|
+
const errorMessage = error && typeof error === 'object' && 'message' in error ? (error as Error).message : '';
|
|
503
|
+
if (!errorMessage.includes('cancel') && !errorMessage.includes('User cancelled')) {
|
|
504
|
+
// 에러 메시지 표시
|
|
505
|
+
Alert.alert('회전 실패', '이미지 회전 중 오류가 발생했습니다.');
|
|
506
|
+
}
|
|
528
507
|
}
|
|
529
508
|
}, [croppedImageData]);
|
|
530
509
|
|