react-native-rectangle-doc-scanner 3.101.0 → 3.103.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
CHANGED
|
@@ -42,7 +42,7 @@ 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
44
|
const react_native_fs_1 = __importDefault(require("react-native-fs"));
|
|
45
|
-
const
|
|
45
|
+
const ImageManipulator = __importStar(require("expo-image-manipulator"));
|
|
46
46
|
const DocScanner_1 = require("./DocScanner");
|
|
47
47
|
const stripFileUri = (value) => value.replace(/^file:\/\//, '');
|
|
48
48
|
const CROPPER_TIMEOUT_MS = 8000;
|
|
@@ -372,38 +372,17 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
|
|
|
372
372
|
setProcessing(true);
|
|
373
373
|
// 회전 각도 정규화 (0, 90, 180, 270)
|
|
374
374
|
const rotationNormalized = ((rotationDegrees % 360) + 360) % 360;
|
|
375
|
-
//
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
rotateCode = 0; // ROTATE_90_CLOCKWISE
|
|
382
|
-
}
|
|
383
|
-
else if (rotationNormalized === 180) {
|
|
384
|
-
rotateCode = 1; // ROTATE_180
|
|
385
|
-
}
|
|
386
|
-
else if (rotationNormalized === 270 || rotationNormalized === -90) {
|
|
387
|
-
rotateCode = 2; // ROTATE_90_COUNTERCLOCKWISE
|
|
388
|
-
}
|
|
389
|
-
else {
|
|
390
|
-
// 회전 없음
|
|
391
|
-
onResult({
|
|
392
|
-
path: croppedImageData.path,
|
|
393
|
-
base64: croppedImageData.base64,
|
|
394
|
-
});
|
|
395
|
-
setProcessing(false);
|
|
396
|
-
return;
|
|
397
|
-
}
|
|
398
|
-
// OpenCV로 이미지 회전
|
|
399
|
-
const rotatedPath = await react_native_fast_opencv_1.Cv2.rotate(croppedImageData.path, rotateCode);
|
|
400
|
-
// 회전된 이미지를 base64로 변환
|
|
401
|
-
const base64Data = await react_native_fs_1.default.readFile(rotatedPath, 'base64');
|
|
375
|
+
// expo-image-manipulator로 이미지 회전
|
|
376
|
+
const result = await ImageManipulator.manipulateAsync(croppedImageData.path, [{ rotate: rotationNormalized }], {
|
|
377
|
+
compress: 0.9,
|
|
378
|
+
format: ImageManipulator.SaveFormat.JPEG,
|
|
379
|
+
base64: true,
|
|
380
|
+
});
|
|
402
381
|
setProcessing(false);
|
|
403
382
|
// 회전된 이미지로 결과 전달
|
|
404
383
|
onResult({
|
|
405
|
-
path:
|
|
406
|
-
base64:
|
|
384
|
+
path: result.uri,
|
|
385
|
+
base64: result.base64,
|
|
407
386
|
});
|
|
408
387
|
}
|
|
409
388
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-rectangle-doc-scanner",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.103.0",
|
|
4
4
|
"description": "Native-backed document scanner for React Native with customizable overlays.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"react": "*",
|
|
35
35
|
"react-native": "*",
|
|
36
|
-
"react-native-fast-opencv": "*",
|
|
37
36
|
"react-native-fs": "*",
|
|
38
37
|
"react-native-image-crop-picker": "*",
|
|
39
38
|
"react-native-image-picker": "*",
|
|
@@ -47,5 +46,7 @@
|
|
|
47
46
|
"react-native-image-picker": "^7.1.2",
|
|
48
47
|
"typescript": "^5.3.3"
|
|
49
48
|
},
|
|
50
|
-
"dependencies": {
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"expo-image-manipulator": "^12.0.5"
|
|
51
|
+
}
|
|
51
52
|
}
|
package/src/FullDocScanner.tsx
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
import { launchImageLibrary } from 'react-native-image-picker';
|
|
13
13
|
import ImageCropPicker from 'react-native-image-crop-picker';
|
|
14
14
|
import RNFS from 'react-native-fs';
|
|
15
|
-
import
|
|
15
|
+
import * as ImageManipulator from 'expo-image-manipulator';
|
|
16
16
|
import { DocScanner } from './DocScanner';
|
|
17
17
|
import type { CapturedDocument } from './types';
|
|
18
18
|
import type {
|
|
@@ -486,39 +486,23 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
|
|
|
486
486
|
// 회전 각도 정규화 (0, 90, 180, 270)
|
|
487
487
|
const rotationNormalized = ((rotationDegrees % 360) + 360) % 360;
|
|
488
488
|
|
|
489
|
-
//
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
rotateCode = 2; // ROTATE_90_COUNTERCLOCKWISE
|
|
500
|
-
} else {
|
|
501
|
-
// 회전 없음
|
|
502
|
-
onResult({
|
|
503
|
-
path: croppedImageData.path,
|
|
504
|
-
base64: croppedImageData.base64,
|
|
505
|
-
});
|
|
506
|
-
setProcessing(false);
|
|
507
|
-
return;
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
// OpenCV로 이미지 회전
|
|
511
|
-
const rotatedPath = await Cv2.rotate(croppedImageData.path, rotateCode);
|
|
512
|
-
|
|
513
|
-
// 회전된 이미지를 base64로 변환
|
|
514
|
-
const base64Data = await RNFS.readFile(rotatedPath, 'base64');
|
|
489
|
+
// expo-image-manipulator로 이미지 회전
|
|
490
|
+
const result = await ImageManipulator.manipulateAsync(
|
|
491
|
+
croppedImageData.path,
|
|
492
|
+
[{ rotate: rotationNormalized }],
|
|
493
|
+
{
|
|
494
|
+
compress: 0.9,
|
|
495
|
+
format: ImageManipulator.SaveFormat.JPEG,
|
|
496
|
+
base64: true,
|
|
497
|
+
}
|
|
498
|
+
);
|
|
515
499
|
|
|
516
500
|
setProcessing(false);
|
|
517
501
|
|
|
518
502
|
// 회전된 이미지로 결과 전달
|
|
519
503
|
onResult({
|
|
520
|
-
path:
|
|
521
|
-
base64:
|
|
504
|
+
path: result.uri,
|
|
505
|
+
base64: result.base64,
|
|
522
506
|
});
|
|
523
507
|
} catch (error) {
|
|
524
508
|
console.error('[FullDocScanner] Image rotation error on confirm:', error);
|