You're viewing documentation for a previous version of this software.Switch to the latest stable version
PESDK/Web/Concepts
Serialization
The PhotoEditor SDK for HTML5 provides an option for serialization and deserialization, allowing your users to save and revise their work anytime.
Since version 3.4.2, PhotoEditorSDK's Editor UI supports serialization and deserialization of application states. This means that you can export the current state of the editor and import it later on.
The serialization schema is specified here.
Serialization#
In order to serialize the editor state, simply call serialize()
on the Editor instance:
editor.serialize({ image: true }).then(state => {console.log('Editor state:', state);});
This will serialize the editor state and write the result to the console.
The image
option specifies whether or not the input image should be serialized as well. Enabling
this (which is the default) will highly increase the size of the resulting object.
Deserialization#
In order to deserialize / load an editor state, simply call deserialize()
on the Editor instance
and pass the editor state object:
editor.deserialize(state).then(() => {console.log('Restored state!');});
This will restore the editor state.