@react-native-ohos/react-native-image-crop-picker 0.40.4 → 0.40.5-rc.1

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 CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.40.5-rc.1
4
+ - Fix the issue where the file size after compression is larger than the original file.
5
+
3
6
  ## v0.40.4-rc.1
4
7
  - react-native-image-crop-picker仓库迁移 ([e09dff16cc4c51bfdcec842921d3c30d49d39a19](https://gitee.com/openharmony-sig/rntpc_react-native-image-crop-picker/pulls/1))
5
8
  - chore: add COMMITTERS.md ([6e71f31b17e5aba5a60215b58ddc6f656def74f9](https://gitee.com/openharmony-sig/rntpc_react-native-image-crop-picker/pulls/2))
@@ -3,7 +3,7 @@
3
3
  "description": "Please describe the basic information.",
4
4
  main: 'index.ets',
5
5
  type: 'module',
6
- version: '0.40.4',
6
+ version: '0.40.5-rc.1',
7
7
  dependencies: {
8
8
  "@rnoh/react-native-openharmony": "^0.72.38"
9
9
  },
@@ -823,30 +823,37 @@ export class ImageCropPickerTurboModule extends TurboModule implements ImageCrop
823
823
  async getFileInfo(includeBase64: boolean, filePath: string, compressOrTempFilePath: string, exifInfo: Exif): Promise<VideoImageInfo> {
824
824
  let videoImageInfo: VideoImageInfo = { duration: null };
825
825
  let imageType;
826
- let i = this.isNullOrUndefined(compressOrTempFilePath) ? filePath.lastIndexOf('/') : compressOrTempFilePath.lastIndexOf('/')
827
- let fileName = this.isNullOrUndefined(compressOrTempFilePath) ? filePath.substring(i + 1) : compressOrTempFilePath.substring(i + 1)
828
- i = filePath.lastIndexOf('.')
826
+
827
+ const targetFilePath = !this.isNullOrUndefined(compressOrTempFilePath) ? compressOrTempFilePath : filePath;
828
+
829
+ let i = targetFilePath.lastIndexOf('/');
830
+ let fileName = targetFilePath.substring(i + 1);
831
+ i = targetFilePath.lastIndexOf('.');
829
832
  if (i != -1) {
830
- imageType = filePath.substring(i + 1)
833
+ imageType = targetFilePath.substring(i + 1);
831
834
  }
832
- videoImageInfo.path = this.isNullOrUndefined(compressOrTempFilePath) ? filePrefix + filePath : compressOrTempFilePath + filePath;
835
+
836
+ videoImageInfo.path = filePrefix + targetFilePath;
833
837
  videoImageInfo.filename = fileName;
834
838
  videoImageInfo.mime = 'image/' + imageType;
835
839
 
836
- let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY)
840
+ let file = fs.openSync(targetFilePath, fs.OpenMode.READ_ONLY)
837
841
  let stat = fs.statSync(file.fd);
838
842
  let length = stat.size;
839
843
  videoImageInfo.size = length;
840
844
  videoImageInfo.creationDate = stat.ctime;
841
845
  videoImageInfo.modificationDate = stat.mtime;
842
- if (this.isImage(filePath)) {
846
+
847
+ if (this.isImage(targetFilePath)) {
843
848
  let imageIS = image.createImageSource(file.fd)
844
849
  let imagePM = await imageIS.createPixelMap()
845
850
  let imgInfo = await imagePM.getImageInfo();
846
- videoImageInfo.data = includeBase64 ? this.imageToBase64(compressOrTempFilePath || filePath) : null;
851
+
852
+ videoImageInfo.data = includeBase64 ? this.imageToBase64(targetFilePath) : null;
847
853
  videoImageInfo.height = imgInfo.size.height;
848
854
  videoImageInfo.width = imgInfo.size.width;
849
855
  videoImageInfo.exif = exifInfo;
856
+
850
857
  imagePM.release().then(() => {
851
858
  imagePM = undefined;
852
859
  })
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-ohos/react-native-image-crop-picker",
3
- "version": "0.40.4",
3
+ "version": "0.40.5-rc.1",
4
4
  "description": "Select single or multiple images, with cropping option",
5
5
  "main": "js/index.js",
6
6
  "scripts": {