Skip to content
This repository was archived by the owner on Dec 13, 2024. It is now read-only.

Commit 6fff13f

Browse files
yangzx18yangzx18
andauthored
fix: 修改返回的base64编码不是压缩后文件的问题 (#36)
* fix: 修改返回的base64编码不是压缩后文件的问题 * refactor: 修改不准确的变量命名 --------- Co-authored-by: yangzx18 <yangzhixian5@h-partners.com>
1 parent b5f7aac commit 6fff13f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

harmony/image_crop_picker/src/main/ets/ImageCropPickerTurboModule.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -693,16 +693,16 @@ export class ImageCropPickerTurboModule extends TurboModule implements TM.ImageC
693693
})
694694
}
695695

696-
async getFileInfo(includeBase64: boolean, filePath: string, tempFilePath: string, exifInfo: Exif) : Promise<VideoImageInfo>{
696+
async getFileInfo(includeBase64: boolean, filePath: string, compressOrTempFilePath: string, exifInfo: Exif) : Promise<VideoImageInfo>{
697697
let videoImageInfo : VideoImageInfo = {duration: null};
698698
let imageType;
699-
let i = this.isNullOrUndefined(tempFilePath) ? filePath.lastIndexOf('/') : tempFilePath.lastIndexOf('/')
700-
let fileName = this.isNullOrUndefined(tempFilePath) ? filePath.substring(i + 1) : tempFilePath.substring(i + 1)
699+
let i = this.isNullOrUndefined(compressOrTempFilePath) ? filePath.lastIndexOf('/') : compressOrTempFilePath.lastIndexOf('/')
700+
let fileName = this.isNullOrUndefined(compressOrTempFilePath) ? filePath.substring(i + 1) : compressOrTempFilePath.substring(i + 1)
701701
i = filePath.lastIndexOf('.')
702702
if (i != -1) {
703703
imageType = filePath.substring(i + 1)
704704
}
705-
videoImageInfo.path = this.isNullOrUndefined(tempFilePath) ? filePrefix + filePath : tempFilePath + filePath;
705+
videoImageInfo.path = this.isNullOrUndefined(compressOrTempFilePath) ? filePrefix + filePath : compressOrTempFilePath + filePath;
706706
videoImageInfo.filename = fileName;
707707
videoImageInfo.mime = 'image/' + imageType;
708708

@@ -716,7 +716,7 @@ export class ImageCropPickerTurboModule extends TurboModule implements TM.ImageC
716716
let imageIS = image.createImageSource(file.fd)
717717
let imagePM = await imageIS.createPixelMap()
718718
let imgInfo = await imagePM.getImageInfo();
719-
videoImageInfo.data = includeBase64 ? this.imageToBase64(filePath) : null;
719+
videoImageInfo.data = includeBase64 ? this.imageToBase64(compressOrTempFilePath || filePath) : null;
720720
videoImageInfo.height = imgInfo.size.height;
721721
videoImageInfo.width = imgInfo.size.width;
722722
videoImageInfo.exif = exifInfo;

0 commit comments

Comments
 (0)