bamlab / react-native-image-resizer

🗻 Resize local images with React Native
MIT License
1.6k stars 342 forks source link

WEBP format doesn't work on iOS? #352

Closed Reagankm closed 1 year ago

Reagankm commented 1 year ago

I'm using "@bam.tech/react-native-image-resizer": "^3.0.4", and I call the resizer like this:

export const resizeImageToMax = (uri: string): Promise<ResizerResponse> => {
    return ImageResizer.createResizedImage(
        uri,
        photoUploadMaxWidth,
        photoUploadMaxWidth,
        'WEBP',
        100,
        0,
        undefined,
        false,
        { onlyScaleDown: true }
    );
}

On Android it works fine. On my iOS emulator I get this error:

 WARN  Possible Unhandled Promise Rejection (id: 1):
Error: Can't save the image. Check your compression format and your output path
Error: Can't save the image. Check your compression format and your output path
    at promiseMethodWrapper (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.CupbearerApp:2383:45)
    at createResizedImage (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.CupbearerApp:126355:43)
    at resizeImageToMax (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.CupbearerApp:126293:63)
    at anonymous (http://localhost:8081/organisms/modals/EditPhotoModal.bundle?platform=ios&modulesOnly=true&app=org.reactjs.native.example.CupbearerApp&dev=true&minify=false&runModule=true&shallow=true:113:95)
    at tryCallOne (/Users/distiller/react-native/sdks/hermes/build_iphonesimulator/lib/InternalBytecode/InternalBytecode.js:53:16)
    at anonymous (/Users/distiller/react-native/sdks/hermes/build_iphonesimulator/lib/InternalBytecode/InternalBytecode.js:139:27)
    at apply (native)
    at anonymous (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.CupbearerApp:30411:26)
    at _callTimer (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.CupbearerApp:30311:17)
    at _callReactNativeMicrotasksPass (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.CupbearerApp:30346:17)
    at callReactNativeMicrotasks (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.CupbearerApp:30554:44)
    at __callReactNativeMicrotasks (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.CupbearerApp:2810:46)
    at anonymous (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.CupbearerApp:2588:45)
    at __guard (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.CupbearerApp:2793:15)
    at flushedQueue (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.CupbearerApp:2587:21)
    at invokeCallbackAndReturnFlushedQueue (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.CupbearerApp:2580:33)

If I change the format to 'JPEG' then it works on iOS, but I really want to use WEBP, especially since it is supported natively as of iOS 14.

taboulot commented 1 year ago

@Reagankm

As specified in the README, WEBP format is at the moment only supported on Android: https://github.com/bamlab/react-native-image-resizer/blob/254e4df2aa2889d223af84006d3a06ce9864a8f1/README.md?plain=1#L86

Any contribution is welcome 🙂

Reagankm commented 1 year ago

Ah. Sorry, I missed that. I went a different way for my resizer library, but I appreciate the work you've put into this. It seems like a great utility

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 1 year ago

This issue has been automatically closed. Thank you for your contributions.