Hi dae! Thank you for the quick reply. I did a little research before posting the suggestion to see if it was technically possible to perform this through url scheme, I should have posted it along with my suggestion!.
I first checked if there was a size limit for url schemes. It seems like there are no limits documented, but in swift core, there is this size check which it seems the limit is 2GB.
// Make sure the URL string isn't too long.
// We're limiting it to 2GB for backwards compatibility with 32-bit executables using NS/CFURL
if ( (urlStringLength > 0) && (urlStringLength <= INT_MAX) )
Knowing this, I tried to create a note using anki’s url-scheme, using as field value a base64 image string. I did two tests, the first one with a 180KB image and another one with a 5MB image and for both cases the note was created successfully.
For the 180kb image, the edit note screen (even tho a bit laggy) opened correctly
end string to the base64 string to check that the whole length was being sent correctly.
For the 5mb image, note editor didn’t display (It was frozen with a white screen), but when repping and checking the card’s back side, the base63 text was shown.
Also, when transforming an UIImage to base64 by using
.pngData()?.base64EncodedString(options:), the returned string doesn’t contain its format at the beginning like the ones present when using CSS (something like
data:image/jpeg;base64), so maybe developers should be encouraged to prepend some kind of flag to let anki know that the field contains a base64 image and it can be parsed correctly:
After retrieving the base64 string, Data’s
init(base64Encoded:options:) can be used to initialize the image’s data and then UIImage’s init(data:) to initialize the UIImage from it.
I hope this info is helpful!.