react-native-rectangle-doc-scanner 3.96.0 → 3.98.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.
@@ -338,17 +338,45 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
338
338
  const newRotation = (prev + degrees + 360) % 360;
339
339
  return newRotation;
340
340
  });
341
- console.log('[FullDocScanner] Starting image rotation...');
341
+ console.log('[FullDocScanner] Starting image rotation...', {
342
+ path: croppedImageData.path,
343
+ hasBase64: !!croppedImageData.base64,
344
+ });
345
+ // file:// prefix 제거
346
+ const cleanPath = croppedImageData.path.replace(/^file:\/\//, '');
342
347
  // ImageRotate를 사용해서 실제로 이미지 회전 (callback 기반)
343
- react_native_image_rotate_1.default.rotateImage(croppedImageData.path, degrees, (rotatedImagePath) => {
344
- console.log('[FullDocScanner] Image rotated successfully:', rotatedImagePath);
345
- // 회전된 이미지로 교체
346
- setCroppedImageData({
347
- path: rotatedImagePath,
348
- base64: undefined, // base64는 다시 읽어야 함
349
- });
350
- // rotation degrees는 0으로 리셋 (이미 실제 파일에 적용되었으므로)
351
- setRotationDegrees(0);
348
+ react_native_image_rotate_1.default.rotateImage(cleanPath, degrees, async (rotatedImageUri) => {
349
+ console.log('[FullDocScanner] Image rotated successfully:', rotatedImageUri);
350
+ try {
351
+ // rct-image-store:// URI를 base64로 변환
352
+ const response = await fetch(rotatedImageUri);
353
+ const blob = await response.blob();
354
+ // Blob to base64
355
+ const reader = new FileReader();
356
+ reader.onloadend = () => {
357
+ const base64String = reader.result;
358
+ // "data:image/jpeg;base64," 부분 제거
359
+ const base64Data = base64String.split(',')[1];
360
+ console.log('[FullDocScanner] Converted rotated image to base64, length:', base64Data?.length);
361
+ // 회전된 이미지로 교체 (base64 포함)
362
+ setCroppedImageData({
363
+ path: rotatedImageUri,
364
+ base64: base64Data,
365
+ });
366
+ // rotation degrees는 0으로 리셋
367
+ setRotationDegrees(0);
368
+ };
369
+ reader.readAsDataURL(blob);
370
+ }
371
+ catch (convertError) {
372
+ console.error('[FullDocScanner] Failed to convert to base64:', convertError);
373
+ // base64 변환 실패 시 URI만 저장
374
+ setCroppedImageData({
375
+ path: rotatedImageUri,
376
+ base64: undefined,
377
+ });
378
+ setRotationDegrees(0);
379
+ }
352
380
  }, (error) => {
353
381
  console.error('[FullDocScanner] Image rotation error:', error);
354
382
  // 에러 발생 시 UI rotation 원복
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "3.96.0",
3
+ "version": "3.98.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -450,23 +450,54 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
450
450
  return newRotation;
451
451
  });
452
452
 
453
- console.log('[FullDocScanner] Starting image rotation...');
453
+ console.log('[FullDocScanner] Starting image rotation...', {
454
+ path: croppedImageData.path,
455
+ hasBase64: !!croppedImageData.base64,
456
+ });
457
+
458
+ // file:// prefix 제거
459
+ const cleanPath = croppedImageData.path.replace(/^file:\/\//, '');
454
460
 
455
461
  // ImageRotate를 사용해서 실제로 이미지 회전 (callback 기반)
456
462
  ImageRotate.rotateImage(
457
- croppedImageData.path,
463
+ cleanPath,
458
464
  degrees,
459
- (rotatedImagePath: string) => {
460
- console.log('[FullDocScanner] Image rotated successfully:', rotatedImagePath);
461
-
462
- // 회전된 이미지로 교체
463
- setCroppedImageData({
464
- path: rotatedImagePath,
465
- base64: undefined, // base64는 다시 읽어야 함
466
- });
467
-
468
- // rotation degrees는 0으로 리셋 (이미 실제 파일에 적용되었으므로)
469
- setRotationDegrees(0);
465
+ async (rotatedImageUri: string) => {
466
+ console.log('[FullDocScanner] Image rotated successfully:', rotatedImageUri);
467
+
468
+ try {
469
+ // rct-image-store:// URI를 base64로 변환
470
+ const response = await fetch(rotatedImageUri);
471
+ const blob = await response.blob();
472
+
473
+ // Blob to base64
474
+ const reader = new FileReader();
475
+ reader.onloadend = () => {
476
+ const base64String = reader.result as string;
477
+ // "data:image/jpeg;base64," 부분 제거
478
+ const base64Data = base64String.split(',')[1];
479
+
480
+ console.log('[FullDocScanner] Converted rotated image to base64, length:', base64Data?.length);
481
+
482
+ // 회전된 이미지로 교체 (base64 포함)
483
+ setCroppedImageData({
484
+ path: rotatedImageUri,
485
+ base64: base64Data,
486
+ });
487
+
488
+ // rotation degrees는 0으로 리셋
489
+ setRotationDegrees(0);
490
+ };
491
+ reader.readAsDataURL(blob);
492
+ } catch (convertError) {
493
+ console.error('[FullDocScanner] Failed to convert to base64:', convertError);
494
+ // base64 변환 실패 시 URI만 저장
495
+ setCroppedImageData({
496
+ path: rotatedImageUri,
497
+ base64: undefined,
498
+ });
499
+ setRotationDegrees(0);
500
+ }
470
501
  },
471
502
  (error: Error) => {
472
503
  console.error('[FullDocScanner] Image rotation error:', error);