I use Photo Editor SDK version 5.0.20 and want to use a serialized settings list with stickers as template for other images.
Basically, I load a previously serialized settings list as described in the Photo Editor SDK Docs, which only contains the operation for the stickers:
{
"version": "3.0.0",
"meta": {
"platform": "android",
"version": "5.0.20",
"createdAt": "2018-04-16T07:22:41+00:00"
},
"operations": [
{
"type": "sprite",
"options": {
"sprites": [
{
"type": "sticker",
"options": {
"identifier": "Wimpel",
"dimensions": {
"x": 1.0390830937992344,
"y": 0.3552596348364971
},
"position": {
"x": 0.093109130859375,
"y": 0.028560863807797432
},
"flipVertically": false,
"flipHorizontally": false,
"tintColor": {
"rgba": [
0.0,
0.0,
0.0,
0.0
]
},
"rotation": 0.10879226105860895
}
},
{
"type": "sticker",
"options": {
"identifier": "Wimpel",
"dimensions": {
"x": 1.0693840954731448,
"y": 0.36561946347204366
},
"position": {
"x": 1.183990716934204,
"y": 0.2119801640510559
},
"flipVertically": false,
"flipHorizontally": false,
"tintColor": {
"rgba": [
0.0,
0.0,
0.0,
0.0
]
},
"rotation": 0.06839104205767087
}
},
{
"type": "sticker",
"options": {
"identifier": "Tasse",
"dimensions": {
"x": 0.4046522174597027,
"y": 0.28636926158686654
},
"position": {
"x": 0.731689453125,
"y": 0.8851687908172607
},
"flipVertically": false,
"flipHorizontally": false,
"tintColor": {
"rgba": [
0.0,
0.0,
0.0,
0.0
]
},
"rotation": 6.279117594930599
}
},
{
"type": "sticker",
"options": {
"identifier": "Mmmh",
"dimensions": {
"x": 0.27350121683039547,
"y": 0.25441973658641437
},
"position": {
"x": 0.604736328125,
"y": 0.7340571284294128
},
"flipVertically": false,
"flipHorizontally": false,
"tintColor": {
"rgba": [
0.0,
0.0,
0.0,
0.0
]
},
"rotation": 6.225312686163292
}
},
{
"type": "sticker",
"options": {
"identifier": "Lachende Shira",
"dimensions": {
"x": 0.32523648876287115,
"y": 0.5730795920977503
},
"position": {
"x": 0.1793212890625,
"y": 0.8109974265098572
},
"flipVertically": false,
"flipHorizontally": false,
"tintColor": {
"rgba": [
0.0,
0.0,
0.0,
0.0
]
},
"rotation": 0.007284810845802748
}
},
{
"type": "sticker",
"options": {
"identifier": "Busch",
"dimensions": {
"x": 0.38570687331007564,
"y": 0.2892801549825567
},
"position": {
"x": 0.157135009765625,
"y": 0.9686249494552612
},
"flipVertically": false,
"flipHorizontally": false,
"tintColor": {
"rgba": [
0.0,
0.0,
0.0,
0.0
]
},
"rotation": 0.010578608482012749
}
}
]
}
}
]
}
These stickers should be displayed on the loaded image, but unfortunately it does not work.
I also tried other serialized settings (e.g. filters), which were correctly applied on the loaded images.
Is there a mistake in the serialized JSON or is something else wrong?
I found out that my custom stickers must be set to the configuration before the serialized JSON is read into the configuration, as otherwise the serialized stickers cannot be found by the SDK:
val settingsList = SettingsList().apply {
...
val tools = arrayListOf<ToolConfigInterface>(...)
val stickers = arrayListOf<StickerListConfigInterface>(...)
config.setTools(tools).setStickerLists(stickers)
val file = File(filesDir.path, "editor_template.json")
if (file.exists()) {
val reader = PESDKFileReader(this)
try {
reader.readJson(file)
Timber.d("Read editor state json.")
} catch (e: IOException) {
Timber.e(e, "Could not read editor state json.")
}
}
}
PhotoEditorBuilder(this).setSettingsList(settingsList).startActivityForResult(this, PHOTO_EDITOR_REQUEST_CODE)