I’m betting the issue lies more with your code than in an inability of SwiftUI to do what you’re trying to do. I’d start figuring it out by checking your assumptions about your variable types, particularly what you’re getting back from the ImagePicker.
It would also help diagnose your problem if you posted more of your code, again particularly the ImagePicker object you are using to get an image.
(And, as a side note, please format your code better so it’s easier to read. Don’t rely on the forum automatically formatting it because it won’t get every line; instead use the triple backtick explicit code formatting as explained in point 5 here.)