react-native-rectangle-doc-scanner 3.102.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,45 +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 = react_native_fast_opencv_1.RotateFlags.ROTATE_180;
|
|
382
|
-
}
|
|
383
|
-
else if (rotationNormalized === 270 || rotationNormalized === -90) {
|
|
384
|
-
rotateCode = react_native_fast_opencv_1.RotateFlags.ROTATE_90_COUNTERCLOCKWISE;
|
|
385
|
-
}
|
|
386
|
-
else {
|
|
387
|
-
// 회전 없음
|
|
388
|
-
onResult({
|
|
389
|
-
path: croppedImageData.path,
|
|
390
|
-
base64: croppedImageData.base64,
|
|
391
|
-
});
|
|
392
|
-
setProcessing(false);
|
|
393
|
-
return;
|
|
394
|
-
}
|
|
395
|
-
// 이미지 파일을 Mat 객체로 로드
|
|
396
|
-
const srcMat = await react_native_fast_opencv_1.OpenCV.invoke('imread', croppedImageData.path);
|
|
397
|
-
// 빈 Mat 객체 생성 (회전된 이미지 저장용)
|
|
398
|
-
const dstMat = new react_native_fast_opencv_1.OpenCV.Mat();
|
|
399
|
-
// OpenCV로 이미지 회전
|
|
400
|
-
react_native_fast_opencv_1.OpenCV.invoke('rotate', srcMat, dstMat, rotateCode);
|
|
401
|
-
// 회전된 이미지를 임시 파일로 저장
|
|
402
|
-
const rotatedPath = `${react_native_fs_1.default.CachesDirectoryPath}/rotated_${Date.now()}.jpg`;
|
|
403
|
-
await react_native_fast_opencv_1.OpenCV.invoke('imwrite', rotatedPath, dstMat);
|
|
404
|
-
// Mat 객체 메모리 해제
|
|
405
|
-
srcMat.delete();
|
|
406
|
-
dstMat.delete();
|
|
407
|
-
// 회전된 이미지를 base64로 변환
|
|
408
|
-
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
|
+
});
|
|
409
381
|
setProcessing(false);
|
|
410
382
|
// 회전된 이미지로 결과 전달
|
|
411
383
|
onResult({
|
|
412
|
-
path:
|
|
413
|
-
base64:
|
|
384
|
+
path: result.uri,
|
|
385
|
+
base64: result.base64,
|
|
414
386
|
});
|
|
415
387
|
}
|
|
416
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,50 +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
|
-
onResult({
|
|
500
|
-
path: croppedImageData.path,
|
|
501
|
-
base64: croppedImageData.base64,
|
|
502
|
-
});
|
|
503
|
-
setProcessing(false);
|
|
504
|
-
return;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
// 이미지 파일을 Mat 객체로 로드
|
|
508
|
-
const srcMat = await OpenCV.invoke('imread', croppedImageData.path);
|
|
509
|
-
|
|
510
|
-
// 빈 Mat 객체 생성 (회전된 이미지 저장용)
|
|
511
|
-
const dstMat = new OpenCV.Mat();
|
|
512
|
-
|
|
513
|
-
// OpenCV로 이미지 회전
|
|
514
|
-
OpenCV.invoke('rotate', srcMat, dstMat, rotateCode);
|
|
515
|
-
|
|
516
|
-
// 회전된 이미지를 임시 파일로 저장
|
|
517
|
-
const rotatedPath = `${RNFS.CachesDirectoryPath}/rotated_${Date.now()}.jpg`;
|
|
518
|
-
await OpenCV.invoke('imwrite', rotatedPath, dstMat);
|
|
519
|
-
|
|
520
|
-
// Mat 객체 메모리 해제
|
|
521
|
-
srcMat.delete();
|
|
522
|
-
dstMat.delete();
|
|
523
|
-
|
|
524
|
-
// 회전된 이미지를 base64로 변환
|
|
525
|
-
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
|
+
);
|
|
526
499
|
|
|
527
500
|
setProcessing(false);
|
|
528
501
|
|
|
529
502
|
// 회전된 이미지로 결과 전달
|
|
530
503
|
onResult({
|
|
531
|
-
path:
|
|
532
|
-
base64:
|
|
504
|
+
path: result.uri,
|
|
505
|
+
base64: result.base64,
|
|
533
506
|
});
|
|
534
507
|
} catch (error) {
|
|
535
508
|
console.error('[FullDocScanner] Image rotation error on confirm:', error);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
declare module 'react-native-fast-opencv' {
|
|
2
|
-
export enum RotateFlags {
|
|
3
|
-
ROTATE_90_CLOCKWISE = 0,
|
|
4
|
-
ROTATE_180 = 1,
|
|
5
|
-
ROTATE_90_COUNTERCLOCKWISE = 2
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export class Mat {
|
|
9
|
-
delete(): void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface OpenCVModel {
|
|
13
|
-
Mat: typeof Mat;
|
|
14
|
-
invoke(name: 'imread', path: string): Promise<Mat>;
|
|
15
|
-
invoke(name: 'imwrite', path: string, mat: Mat): Promise<void>;
|
|
16
|
-
invoke(name: 'rotate', src: Mat, dst: Mat, code: RotateFlags): void;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const OpenCV: OpenCVModel;
|
|
20
|
-
}
|