thorvg_python.saver¶
Classes¶
Saver API |
Module Contents¶
-
class thorvg_python.saver.Saver(engine: thorvg_python.engine.Engine, saver: thorvg_python.base.SaverPointer | None =
None)¶ Saver 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.
- engine¶
- thorvg_lib¶
- _new() thorvg_python.base.SaverPointer¶
Creates a new SaverPointer object.
Note
You need not call this method as it is auto called when initializing
Saver().
- save_paint(paint: thorvg_python.paint.Paint, path: str, quality: int) thorvg_python.base.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:¶
- paint : thorvg_python.paint.Paint¶
The paint to be saved with all its associated properties.
- path : str¶
A path to the file, in which the paint data is to be saved.
- quality : bool¶
If
truethen compress data if possible.
- Returns:¶
Result.INVALID_ARGUMENT A
Nonepassed as the argument.Result.INSUFFICIENT_CONDITION Currently saving other resources.
Result.NOT_SUPPORTED Trying to save a file with an unknown extension or in an unsupported format.
Result.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()
- save_animation(animation: thorvg_python.animation.Animation, path: str, quality: int, fps: int) thorvg_python.base.Result¶
Exports the given
animationdata 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:¶
- animation : thorvg_python.animation.Animation¶
The animation to be saved with all its associated properties.
- path : str¶
A path to the file, in which the animation data is to be saved.
- quality : int¶
The encoded quality level.
0is the minimum,100is the maximum value(recommended).- fps : int¶
The frames per second for the animation. If
0, the default fps is used.
- Returns:¶
Result.INVALID_ARGUMENT A
Nonepassed as the argument.Result.INSUFFICIENT_CONDITION Currently saving other resources or animation has no frames.
Result.NOT_SUPPORTED Trying to save a file with an unknown extension or in an unsupported format.
Result.UNKNOWN Unknown if attempting to save an empty paint.
- Return type:¶
Note
A higher frames per second (FPS) would result in a larger file size. It is recommended to use the default value.
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()
Added in version 1.0.
- sync() thorvg_python.base.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:¶
Result.INVALID_ARGUMENT A
Nonepassed as the argument.Result.INSUFFICIENT_CONDITION No saving task is running.
- Return type:¶
Note
The asynchronous tasking is dependent on the Saver module implementation.
See also
Saver.save()
- _del() thorvg_python.base.Result¶
Deletes the given SaverPointer object.