NervJS / taro

开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发微信/京东/百度/支付宝/字节跳动/ QQ 小程序/H5/React Native 等应用。 https://taro.zone/
https://docs.taro.zone/
Other
35.68k stars 4.79k forks source link

@bam.tech/react-native-image-resizer 在ios开启新架构的情况下编译报错 #16497

Open ShaoGongBra opened 2 months ago

ShaoGongBra commented 2 months ago

相关平台

React Native

使用框架: React

复现步骤

建议可以换成expo-image-manipulator 也能实现压缩图片的功能

期望结果

1

实际结果

2

环境信息

Taro CLI 4.0.5 environment info:
    System:
      OS: macOS 14.5
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 18.20.3 - /var/folders/rf/gd60z12164z72bny7z_0d4f80000gn/T/yarn--1725775872798-0.9386574313685347/node
      Yarn: 1.22.22 - /var/folders/rf/gd60z12164z72bny7z_0d4f80000gn/T/yarn--1725775872798-0.9386574313685347/yarn
      npm: 10.7.0 - ~/.nvm/versions/node/v18.20.3/bin/npm
    npmPackages:
      @tarojs/cli: 4.0.5 => 4.0.5 
      @tarojs/components: 4.0.5 => 4.0.5 
      @tarojs/helper: 4.0.5 => 4.0.5 
      @tarojs/plugin-framework-react: 4.0.5 => 4.0.5 
      @tarojs/plugin-platform-alipay: 4.0.5 => 4.0.5 
      @tarojs/plugin-platform-h5: 4.0.5 => 4.0.5 
      @tarojs/plugin-platform-jd: 4.0.5 => 4.0.5 
      @tarojs/plugin-platform-qq: 4.0.5 => 4.0.5 
      @tarojs/plugin-platform-swan: 4.0.5 => 4.0.5 
      @tarojs/plugin-platform-tt: 4.0.5 => 4.0.5 
      @tarojs/plugin-platform-weapp: 4.0.5 => 4.0.5 
      @tarojs/react: 4.0.5 => 4.0.5 
      @tarojs/rn-runner: 4.0.5 => 4.0.5 
      @tarojs/rn-supporter: 4.0.5 => 4.0.5 
      @tarojs/runtime: 4.0.5 => 4.0.5 
      @tarojs/shared: 4.0.5 => 4.0.5 
      @tarojs/taro: 4.0.5 => 4.0.5 
      @tarojs/taro-loader: 4.0.5 => 4.0.5 
      @tarojs/taro-rn: 4.0.5 => 4.0.5 
      @tarojs/webpack5-runner: 4.0.5 => 4.0.5 
      babel-preset-taro: 4.0.5 => 4.0.5 
      eslint-config-taro: 4.0.5 => 4.0.5 
      expo: ~51.0.32 => 51.0.32 
      react: ^18.2.0 => 18.3.1 
      react-native: ~0.75.2 => 0.75.2
ShaoGongBra commented 2 months ago

这是修改参考

diff --git a/node_modules/@tarojs/taro-rn/dist/lib/compressImage/index.js b/node_modules/@tarojs/taro-rn/dist/lib/compressImage/index.js
index 9549762..32838ed 100644
--- a/node_modules/@tarojs/taro-rn/dist/lib/compressImage/index.js
+++ b/node_modules/@tarojs/taro-rn/dist/lib/compressImage/index.js
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
         step((generator = generator.apply(thisArg, _arguments || [])).next());
     });
 };
-import ImageResizer from '@bam.tech/react-native-image-resizer';
+import { manipulateAsync, SaveFormat } from 'expo-image-manipulator';
 import { Image } from 'react-native';
 import { errorHandler, successHandler } from '../../utils';
 /**
@@ -20,8 +20,13 @@ export function compressImage(opt) {
         const res = { errMsg: 'compressImage:ok', tempFilePath: '' };
         const _createResizedImage = (...args_1) => __awaiter(this, [...args_1], void 0, function* (width = 800, height = 800) {
             try {
-                const compressFormat = src.toLocaleLowerCase().endsWith('.png') ? 'PNG' : 'JPEG';
-                const { uri } = yield ImageResizer.createResizedImage(src, width, height, compressFormat, quality);
+                const compressFormat = src.toLocaleLowerCase().endsWith('.png') ? SaveFormat.PNG : SaveFormat.JPEG;
+                const { uri } = yield manipulateAsync(src, [
+                  { resize: { width, height }}
+                ], {
+                  compress: quality,
+                  format: compressFormat
+                });
                 res.tempFilePath = uri;
                 return successHandler(success, complete)(res);
             }