Image
ImageAssetParams
Bases: BaseModel
Represents the parameters for an image assets.
position
class-attribute
instance-attribute
position: Position = Field(default_factory=AbsolutePosition)
The positioning of the text assets in the video.
crop
class-attribute
instance-attribute
The crop range for the image assets.
as_background
class-attribute
instance-attribute
as_background: bool = True
Whether the image should be used as a background.
ImageAsset
Bases: BaseAsset[ImageAssetParams]
Represents an image assets with various properties.
type
class-attribute
instance-attribute
type: Literal['image'] = 'image'
The type of the assets. Defaults to "image".
params
class-attribute
instance-attribute
params: ImageAssetParams = Field(
default_factory=ImageAssetParams
)
The parameters for the assets.
from_data
classmethod
from_data(
data: str | bytes,
*,
path: PathLike | None = None,
metadata: dict | None = None,
mime_type: str | None = None,
**kwargs: Any
) -> Self
Creates an image asset from data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
str | bytes
|
The data of the assets. |
required |
path |
PathLike | None
|
The path to the file. |
None
|
metadata |
dict | None
|
The metadata of the assets. |
None
|
mime_type |
str | None
|
The MIME type of the assets. |
None
|
kwargs |
Any
|
Additional keyword arguments to the constructor. |
{}
|
Returns:
Type | Description |
---|---|
Self
|
The assets. |
Source code in src/mosaico/assets/image.py
from_path
classmethod
from_path(
path: PathLike,
*,
encoding: str = "utf-8",
mime_type: str | None = None,
guess_mime_type: bool = True,
metadata: dict | None = None,
**kwargs: Any
) -> Self
Creates an image asset from a file path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
PathLike
|
The path to the file. |
required |
encoding |
str
|
The encoding of the file. |
'utf-8'
|
metadata |
dict | None
|
The metadata of the assets. |
None
|
mime_type |
str | None
|
The MIME type of the assets. |
None
|
guess_mime_type |
bool
|
Whether to guess the MIME type. |
True
|
kwargs |
Any
|
Additional keyword arguments to the constructor. |
{}
|
Returns:
Type | Description |
---|---|
Self
|
The assets. |