thorvg_python.saver¶
-
class thorvg_python.saver.Saver(engine: Engine, saver: SaverStruct | None =
None)¶ Bases:
objectSaver API
A module for exporting a paint object into a specified file.
The module enables to save the composed scene and/or image from a paint object. Once it’s successfully exported to a file, it can be recreated using the Picture module.
- save(paint: Paint, path: str, compress: bool) Result¶
Exports the given
paintdata to the givenpathIf the saver module supports any compression mechanism, it will optimize the data size. This might affect the encoding/decoding time in some cases. You can turn off the compression if you wish to optimize for speed.
- Parameters:¶
- Returns:¶
INVALID_ARGUMENT A
nullptrpassed as the argument.INSUFFICIENT_CONDITION Currently saving other resources.
NOT_SUPPORTED Trying to save a file with an unknown extension or in an unsupported format.
UNKNOWN An empty paint is to be saved.
- Return type:¶
Note
Saving can be asynchronous if the assigned thread number is greater than zero. To guarantee the saving is done, call Saver.sync() afterwards.
See also
Saver.sync()
- sync() Result¶
Guarantees that the saving task is finished.
The behavior of the Saver module works on a sync/async basis, depending on the threading setting of the Initializer. Thus, if you wish to have a benefit of it, you must call Saver.sync() after the Saver.save() in the proper delayed time. Otherwise, you can call Saver.sync() immediately.
- Returns:¶
INVALID_ARGUMENT A
nullptrpassed as the argument.INSUFFICIENT_CONDITION No saving task is running.
- Return type:¶
Note
The asynchronous tasking is dependent on the Saver module implementation.
See also
Saver.save()