@react-native-ohos/react-native-image-crop-picker 0.51.2-rc.3 → 0.51.2-rc.6
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/CHANGELOG.md +17 -0
- package/harmony/image_crop_picker/oh-package.json5 +1 -1
- package/harmony/image_crop_picker/src/main/ets/ImageCropPickerTurboModule.ts +22 -20
- package/harmony/image_crop_picker/src/main/ets/generated/turboModules/ImageCropPicker.ts +1 -1
- package/harmony/image_crop_picker/src/main/ets/pages/CircleImageInfo.ets +1 -1
- package/harmony/image_crop_picker/src/main/ets/pages/ImageEditInfo.ets +1066 -172
- package/harmony/image_crop_picker/src/main/ets/utils/EncodeUtil.ets +1 -5
- package/harmony/image_crop_picker.har +0 -0
- package/index.d.ts +11 -3
- package/package.json +1 -1
- package/packages/rnoh-react-native-harmony-cli-0.82.1.tgz +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
## 鸿蒙化Log
|
|
4
4
|
|
|
5
|
+
### v0.51.2-rc.6
|
|
6
|
+
|
|
7
|
+
- fix: Adjust the saved format after image cropping and compression
|
|
8
|
+
- pre-release: @react-native-ohos/react-native-image-crop-picker@0.51.2-rc.6
|
|
9
|
+
|
|
10
|
+
### v0.51.2-rc.5
|
|
11
|
+
|
|
12
|
+
- fix: Add the "freeStyleCropEnabled" attribute
|
|
13
|
+
- pre-release: @react-native-ohos/react-native-image-crop-picker@0.51.2-rc.5
|
|
14
|
+
|
|
15
|
+
### v0.51.2-rc.4
|
|
16
|
+
|
|
17
|
+
- Fix: Support for multiple image formats in image compression. Fixed issues with openPicker and openCamera where circular cropping of images did not display properly.
|
|
18
|
+
- Fix: Adjust to retain the original format of the image after cropping it.
|
|
19
|
+
- Fix: Address the issue where the image cropping frame cannot be dragged. Optimize the position dragging of the cropping frame to ensure it remains centered and maintains consistent iOS effect.
|
|
20
|
+
- pre-release: @react-native-ohos/react-native-image-crop-picker@0.51.2-rc.4
|
|
21
|
+
|
|
5
22
|
### v0.51.2-rc.3
|
|
6
23
|
|
|
7
24
|
- fix: The issue of the PNG image being larger in memory than the one generated with a compression ratio of 0.8 to 1 has been resolved.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Please describe the basic information.",
|
|
4
4
|
"main": "index.ets",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "0.51.2-rc.
|
|
6
|
+
"version": "0.51.2-rc.6",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@rnoh/react-native-openharmony": "file:../../node_modules/@react-native-oh/react-native-harmony/harmony/react_native_openharmony.har"
|
|
9
9
|
},
|
|
@@ -550,7 +550,13 @@ export class ImageCropPickerTurboModule extends TurboModule implements ImageCrop
|
|
|
550
550
|
if (isImg) {
|
|
551
551
|
let file = fs.openSync(imgOrVideoPath, fs.OpenMode.READ_ONLY);
|
|
552
552
|
try {
|
|
553
|
-
let
|
|
553
|
+
let i = imgOrVideoPath.lastIndexOf('.');
|
|
554
|
+
let imageType = '';
|
|
555
|
+
if (i != -1) {
|
|
556
|
+
imageType = imgOrVideoPath.substring(i + 1);
|
|
557
|
+
Logger.info(`${TAG} getTempFilePaths img imageType = ${imageType}`);
|
|
558
|
+
}
|
|
559
|
+
let dstPath = this.ctx.uiAbilityContext.tempDir + '/rn_image_crop_picker_lib_temp_' + util.generateRandomUUID(true) + '.' + imageType;
|
|
554
560
|
fs.copyFileSync(file.fd, dstPath, 0);
|
|
555
561
|
imgOrVideoPath = dstPath;
|
|
556
562
|
Logger.info(`${TAG} into openCamera suc dstPath = ${dstPath}`);
|
|
@@ -666,7 +672,8 @@ export class ImageCropPickerTurboModule extends TurboModule implements ImageCrop
|
|
|
666
672
|
|
|
667
673
|
isImage(filePath: string): boolean {
|
|
668
674
|
Logger.info(`${TAG} into isImage fileName = ${filePath}`);
|
|
669
|
-
const imageExtensionsRegex =
|
|
675
|
+
const imageExtensionsRegex =
|
|
676
|
+
/\.(jpg|jpeg|png|gif|bmp|webp|heic|heif|sdr_astc_4x4|sdr_sut_superfast_4x4|hdr_astc_4x4)$/i;
|
|
670
677
|
return imageExtensionsRegex.test(filePath);
|
|
671
678
|
}
|
|
672
679
|
|
|
@@ -691,24 +698,19 @@ export class ImageCropPickerTurboModule extends TurboModule implements ImageCrop
|
|
|
691
698
|
let imageISs = image.createImageSource(files.fd);
|
|
692
699
|
let imagePMs = await imageISs.createPixelMap();
|
|
693
700
|
let imagePackerApi = await image.createImagePacker();
|
|
694
|
-
let
|
|
701
|
+
let dstPath =
|
|
702
|
+
this.ctx.uiAbilityContext.tempDir + '/rn_image_crop_picker_lib_temp_' + util.generateRandomUUID(true) +
|
|
703
|
+
'.' + imageType;
|
|
695
704
|
let options: image.PackingOption = {
|
|
696
|
-
format: `image
|
|
705
|
+
format: `image/jpeg`,
|
|
697
706
|
quality: quality,
|
|
698
707
|
};
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
const number = fs.writeSync(newFile.fd, packerData);
|
|
706
|
-
Logger.info(`${TAG} into compressPictures write data to file succeed size = ${number}`);
|
|
707
|
-
resultImages.push(dstPath);
|
|
708
|
-
fs.closeSync(files);
|
|
709
|
-
} catch (err) {
|
|
710
|
-
Logger.error(`${TAG} into compressPictures write data to file failed err = ${JSON.stringify(err)}`);
|
|
711
|
-
}
|
|
708
|
+
let newFile = fs.openSync(dstPath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
|
|
709
|
+
let packerData = await imagePackerApi.packToData(imagePMs, options);
|
|
710
|
+
const number = fs.writeSync(newFile.fd, packerData);
|
|
711
|
+
fs.closeSync(newFile);
|
|
712
|
+
resultImages.push(dstPath);
|
|
713
|
+
fs.closeSync(files);
|
|
712
714
|
} else {
|
|
713
715
|
Logger.info(`${TAG} into compressPictures video srcPath = ${srcPath}`);
|
|
714
716
|
resultImages.push(srcPath);
|
|
@@ -1070,9 +1072,9 @@ export class ImageCropPickerTurboModule extends TurboModule implements ImageCrop
|
|
|
1070
1072
|
.then((data: PermissionRequestResult) => {
|
|
1071
1073
|
res(data?.authResults[0] === 0)
|
|
1072
1074
|
}).catch((err) => {
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1075
|
+
res(false)
|
|
1076
|
+
Logger.info(`${TAG} grantPermission err = ${JSON.stringify(err)}`);
|
|
1077
|
+
})
|
|
1076
1078
|
});
|
|
1077
1079
|
}
|
|
1078
1080
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
export namespace ImageCropPicker {
|
|
6
6
|
export const NAME = 'ImageCropPicker' as const
|
|
7
7
|
|
|
8
|
-
export type CropperOptions = {multiple?: boolean, minFiles?: number, maxFiles?: number, waitAnimationEnd?: boolean, smartAlbums?: unknown[], useFrontCamera?: boolean, loadingLabelText?: string, showsSelectedCount?: boolean, sortOrder?: string, hideBottomControls?: boolean, writeTempFile?: boolean, mediaType: string, width?: number, height?: number, includeBase64?: boolean, includeExif?: boolean, forceJpg?: boolean, cropping?: boolean, avoidEmptySpaceAroundImage?: boolean, cropperActiveWidgetColor?: string,
|
|
8
|
+
export type CropperOptions = {multiple?: boolean, minFiles?: number, maxFiles?: number, waitAnimationEnd?: boolean, smartAlbums?: unknown[], useFrontCamera?: boolean, loadingLabelText?: string, showsSelectedCount?: boolean, sortOrder?: string, hideBottomControls?: boolean, writeTempFile?: boolean, mediaType: string, width?: number, height?: number, includeBase64?: boolean, includeExif?: boolean, forceJpg?: boolean, cropping?: boolean, avoidEmptySpaceAroundImage?: boolean, cropperActiveWidgetColor?: string, cropperStatusBarLight?: boolean, cropperNavigationBarLight?: boolean, cropperToolbarColor?: string, cropperToolbarWidgetColor?: string, cropperToolbarTitle?: string, freeStyleCropEnabled?: boolean, cropperTintColor?: string, cropperCircleOverlay?: boolean, cropperCancelText?: string, cropperCancelColor?: string, cropperChooseText?: string, cropperChooseColor?: string, cropperRotateButtonHidden?: boolean, showCropGuidelines?: boolean, showCropFrame?: boolean, enableRotationGesture?: boolean, disableCropperColorSetters?: boolean, compressImageMaxWidth?: number, compressImageMaxHeight?: number, compressImageQuality?: number, path: string}
|
|
9
9
|
|
|
10
10
|
export type Exif = {}
|
|
11
11
|
|