react-native-rectangle-doc-scanner 3.96.0 → 3.97.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 +32 -9
- package/package.json +1 -1
- package/src/FullDocScanner.tsx +36 -11
package/dist/FullDocScanner.js
CHANGED
|
@@ -340,15 +340,38 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
|
|
|
340
340
|
});
|
|
341
341
|
console.log('[FullDocScanner] Starting image rotation...');
|
|
342
342
|
// ImageRotate를 사용해서 실제로 이미지 회전 (callback 기반)
|
|
343
|
-
react_native_image_rotate_1.default.rotateImage(croppedImageData.path, degrees, (
|
|
344
|
-
console.log('[FullDocScanner] Image rotated successfully:',
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
343
|
+
react_native_image_rotate_1.default.rotateImage(croppedImageData.path, degrees, async (rotatedImageUri) => {
|
|
344
|
+
console.log('[FullDocScanner] Image rotated successfully:', rotatedImageUri);
|
|
345
|
+
try {
|
|
346
|
+
// rct-image-store:// URI를 base64로 변환
|
|
347
|
+
const response = await fetch(rotatedImageUri);
|
|
348
|
+
const blob = await response.blob();
|
|
349
|
+
// Blob to base64
|
|
350
|
+
const reader = new FileReader();
|
|
351
|
+
reader.onloadend = () => {
|
|
352
|
+
const base64String = reader.result;
|
|
353
|
+
// "data:image/jpeg;base64," 부분 제거
|
|
354
|
+
const base64Data = base64String.split(',')[1];
|
|
355
|
+
console.log('[FullDocScanner] Converted to base64, length:', base64Data?.length);
|
|
356
|
+
// 회전된 이미지로 교체 (base64 포함)
|
|
357
|
+
setCroppedImageData({
|
|
358
|
+
path: rotatedImageUri,
|
|
359
|
+
base64: base64Data,
|
|
360
|
+
});
|
|
361
|
+
// rotation degrees는 0으로 리셋
|
|
362
|
+
setRotationDegrees(0);
|
|
363
|
+
};
|
|
364
|
+
reader.readAsDataURL(blob);
|
|
365
|
+
}
|
|
366
|
+
catch (convertError) {
|
|
367
|
+
console.error('[FullDocScanner] Failed to convert to base64:', convertError);
|
|
368
|
+
// base64 변환 실패 시 URI만 저장
|
|
369
|
+
setCroppedImageData({
|
|
370
|
+
path: rotatedImageUri,
|
|
371
|
+
base64: undefined,
|
|
372
|
+
});
|
|
373
|
+
setRotationDegrees(0);
|
|
374
|
+
}
|
|
352
375
|
}, (error) => {
|
|
353
376
|
console.error('[FullDocScanner] Image rotation error:', error);
|
|
354
377
|
// 에러 발생 시 UI rotation 원복
|
package/package.json
CHANGED
package/src/FullDocScanner.tsx
CHANGED
|
@@ -456,17 +456,42 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
|
|
|
456
456
|
ImageRotate.rotateImage(
|
|
457
457
|
croppedImageData.path,
|
|
458
458
|
degrees,
|
|
459
|
-
(
|
|
460
|
-
console.log('[FullDocScanner] Image rotated successfully:',
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
459
|
+
async (rotatedImageUri: string) => {
|
|
460
|
+
console.log('[FullDocScanner] Image rotated successfully:', rotatedImageUri);
|
|
461
|
+
|
|
462
|
+
try {
|
|
463
|
+
// rct-image-store:// URI를 base64로 변환
|
|
464
|
+
const response = await fetch(rotatedImageUri);
|
|
465
|
+
const blob = await response.blob();
|
|
466
|
+
|
|
467
|
+
// Blob to base64
|
|
468
|
+
const reader = new FileReader();
|
|
469
|
+
reader.onloadend = () => {
|
|
470
|
+
const base64String = reader.result as string;
|
|
471
|
+
// "data:image/jpeg;base64," 부분 제거
|
|
472
|
+
const base64Data = base64String.split(',')[1];
|
|
473
|
+
|
|
474
|
+
console.log('[FullDocScanner] Converted to base64, length:', base64Data?.length);
|
|
475
|
+
|
|
476
|
+
// 회전된 이미지로 교체 (base64 포함)
|
|
477
|
+
setCroppedImageData({
|
|
478
|
+
path: rotatedImageUri,
|
|
479
|
+
base64: base64Data,
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
// rotation degrees는 0으로 리셋
|
|
483
|
+
setRotationDegrees(0);
|
|
484
|
+
};
|
|
485
|
+
reader.readAsDataURL(blob);
|
|
486
|
+
} catch (convertError) {
|
|
487
|
+
console.error('[FullDocScanner] Failed to convert to base64:', convertError);
|
|
488
|
+
// base64 변환 실패 시 URI만 저장
|
|
489
|
+
setCroppedImageData({
|
|
490
|
+
path: rotatedImageUri,
|
|
491
|
+
base64: undefined,
|
|
492
|
+
});
|
|
493
|
+
setRotationDegrees(0);
|
|
494
|
+
}
|
|
470
495
|
},
|
|
471
496
|
(error: Error) => {
|
|
472
497
|
console.error('[FullDocScanner] Image rotation error:', error);
|