decodeJpeg() function don't work in react native
See original GitHub issueSo I basically copy the same code from the doc (https://blog.tensorflow.org/2020/02/tensorflowjs-for-react-native-is-here.html) about using tensorflow in react native. However when I want to call decodeJpeg function it returns an error
Error: Expected image (JPEG, PNG, or GIF), but got unsupported image type getImageType@http://192.168.0.141:8081/index.bundle?platform=ios&dev=true&minify=false:377324:22
I tried different ways and don’t know if my setup is wrong or the doc is wrong Below is what I tried (1)
const response = await fetch(imageurl, {}, {isBinary: true});
const imageData = await response.arrayBuffer();
const img = decodeJpeg(imageData);
(2)
const img = decodeJpeg(imageurl)
the imageurl is from iPhone photo library so technically it’s not from online but I think they should work the same. Do I need to show more setup?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
can't find decodeJpeg from tfjs-react-native - Stack Overflow
i want to tensorflow-js with react-native so i read document. in there, write when image to tensor use decodeJpeg. but can't find decodeJpeg....
Read more >Top 5 jpeg-js Code Examples - Snyk
Learn more about how to use jpeg-js, based on jpeg-js code examples created from the most popular ways it is used in public...
Read more >Images - React Native
In React Native, image decoding is done in a different thread. In practice, you already need to handle the case when the image...
Read more >Blob - The Modern JavaScript Tutorial
By default "transparent" (do nothing), but also can be "native" (transform). ... as the mapping is removed, the URL doesn't work any more....
Read more >Picture perfect images with the modern <img> element
You may not think about images as part of your web dev work, ... like Next.js <Image> (for React) and Nuxt image (for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Could you try wrapping your arraybuffer in a UInt8Array similar to this example https://js.tensorflow.org/api_react_native/0.5.0/#decodeJpeg.
If that doesn’t work could you upload a sample image file that shows this behaviour.
Are you satisfied with the resolution of your issue? Yes No