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

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.2',
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
  })
@@ -129,6 +129,7 @@ export struct ImageEditInfo {
129
129
  private minSize = PHONE_MIN_CROP // 最小宽高
130
130
  private dragObj: DragObj = new DragObj(false);
131
131
  private clb: number = 1
132
+ private canClip: boolean = true
132
133
 
133
134
  pixelInit(path: string) {
134
135
  this.angle = 0;
@@ -180,6 +181,9 @@ export struct ImageEditInfo {
180
181
  top = (screenHeight - this.initHeight) / 2 - 66;
181
182
  bottom = this.initHeight + top;
182
183
  }
184
+ if(!!this.initWidth && !!this.initHeight){
185
+ this.canClip = false
186
+ }
183
187
 
184
188
  this.clipSize = new Rectangle(left, top, right, bottom);
185
189
  this.display = new Rectangle(0, 0, this.screenWidth, this.screenHeight - 66 * 2);
@@ -559,6 +563,9 @@ export struct ImageEditInfo {
559
563
  let newPosition = this.clipSize.clone();
560
564
 
561
565
  let direction = this.dragObj.action;
566
+
567
+ if(!this.canClip) return;
568
+
562
569
  if (this.dragObj.multiCrop) {
563
570
  this.getMultiCropRect(delX, delY, newPosition, direction, event.pressure);
564
571
  } else {
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.2",
4
4
  "description": "Select single or multiple images, with cropping option",
5
5
  "main": "js/index.js",
6
6
  "scripts": {