Serialization
PhotoEditor SDK supports serialization and deserialization, allowing your users to save and revise their work at any time. Serialization requires the backend:serializer
module. Refer to our documentation on how to include the module in your project.
Start Editor#
For the sake of this example, we load a photo from the resources into the photo editor.
Configure the PhotoEditorSaveSettings
to set the outputMode
to only export the SettingsList
(instead of the photo). This SettingsList
will be used later for serialization. You can choose to skip this step and both the photo as well as the SettingsList
will be exported.
Handle Result#
The result from the editor is received in the onActivityResult()
method. EditorSDKResult
wraps around the intent and provides a convenient API to check the result. Here, we launch a coroutine using Dispatchers.IO
. Inside the coroutine, we create a file, obtain the SettingsList
(via EditorSDKResult.settingsList
), and serialize it using the IMGLYFileWriter.writeJson()
method. You can optionally serialize the SettingsList
into a String
(using IMGLYFileWriter.writeJsonAsString()
) or a ByteArray
(using IMGLYFileWriter.writeJsonAsBytes()
).
For details on the JSON structure you can download our schema.
For further processing, you can upload the serialization to a remote server (compare Save Photo To Remote URL) to make the editor state available on other devices as well.
The next section explains how to restore the editor state by deserializing these settings.