I know that the ImageManipulator works with SVG in a web client, but in iOS and Android it errors when trying to read the SVG. Is it because there’s an issue with my SVG, or is it because SVGs aren’t supported on mobile platforms?
If I can’t use the ImageManipulator, can anyone suggest how I could do the conversion on iOS and Android?
Thanks
Please provide the following:
SDK Version: 47 onwards
Platforms(Android/iOS/web/all): iOS and Android
Add the appropriate “Tag” based on what Expo library you have a question on.
Sure @wodin, I’m using SVG to capture a list of annotations to an image taken with the device’s camera. The SVG has an image component and then a list of paths drawn over the top. This works a treat as you can undo and redo changes etc. But the server is currently expect a JPG or PNG. If I could convert the SVG image into a JPG on save, then all my existing server-side code will “just work” with the annotated image. But if I have to cater for SVG images then I’m going to have to make a lot of changes server-side. The annotated image will eventually (among other things) be rendered into a PDF document.
I see. Well, one thing: If you convert it to JPEG it will lose some quality, whereas if you convert to PNG it will not. So if you have to convert it to a raster image format I would rather use PNG.
Unfortunately I’m not sure how to do it. If you can find a React Native library that can do it you should be able to use it from Expo.
react-native-skia does seem to have a way to render an SVG to a canvas and then get a snapshot of the canvas, but I’m not sure what format the data is in and whether you can convert that to a PNG.
You could possibly write a simple native module to do it. This is a lot easier than it used to be with Expo Modules.
If you want to try creating an Expo Module, you might search for things like “kotlin convert svg to png” or “java convert svg to png”, and similar for Swift/Objective C.