ooodev.format.writer.direct.image.crop package
Module contents
- class ooodev.format.writer.direct.image.crop.CropOpt(*, left=0, right=0, top=0, bottom=0, all=None, keep_scale=True)[source]
Bases:
CropStruct
- __init__(*, left=0, right=0, top=0, bottom=0, all=None, keep_scale=True)[source]
Constructor
- Parameters:
left (float, UnitT, optional) – Specifies left crop in
mm
units or Class UnitT. Default0.0
.right (float, UnitT, optional) – Specifies right crop in
mm
units or Class UnitT. Default0.0
.top (float, UnitT, optional) – Specifies top crop in
mm
units or Class UnitT. Default0.0
.bottom (float, UnitT, optional) – Specifies bottom crop in
mm
units or Class UnitT. Default0.0
.keep_scale (bool, optional) – If
True
then crop isall (float, UnitT, optional) – Specifies
left
,right
,top
, andbottom
inmm
units or Class UnitT. If set all other parameters are ignored.keep_scale – If
True
crop is applied keeping image scale; Otherwise crop is applied keeping image size. Defaults toTrue
.
- Return type:
None
- can_crop()[source]
Gets if values are valid for crop.
- Returns:
True
if options are valid; Otherwise,False
.- Return type:
bool
- property prop_keep_scale: bool
Gets/Sets keep scale.
- Return type:
bool
- class ooodev.format.writer.direct.image.crop.ImageCrop(*, crop=None, img_size=None, img_scale=None)[source]
Bases:
StyleMulti
Crops and/or resizes an image.
General Rules.
Crop Rules
Rules for
CropOpt.keep_scale=True
.If scale is passed in then image size is to be calculated from that scale using original image values, factoring in crop values.
If scale is not passed in image size is calculated from 100% using original image values, factoring in crop values.
If Image size is passed in then it is ignored.
Rules for
CropOpt.keep_scale=False
.If image size is passed in then it is used to set image size, factoring in crop values.
If image size is not passed in then then the original image size is used to set image size, factoring in crop values.
No Crop Rules
Rules when crop is not passed to constructor.
If image size is present it is used to set the image size. In this case scale is ignored. Any existing Crop values are ignored.
If scale is present but no image size is present then a new size is derived from original size using scale.
If both image size and scale size are present then scale is ignored.
New in version 0.9.0.
- apply(obj: Any)[source]
- apply(obj: Any, **kwargs)
- apply(obj, **kwargs)
Applies style of current instance.
- Parameters:
obj (Any) – UNO Object that styles are to be applied.
- Return type:
None
- copy()[source]
- copy(**kwargs)
- copy(**kwargs)
Gets a copy of instance as a new instance
- Return type:
TypeVar
(_TImageCrop
, bound= ImageCrop)- Parameters:
self (_TImageCrop) –
- classmethod from_obj(obj)[source]
- classmethod from_obj(obj, **kwargs)
- classmethod from_obj(obj, **kwargs)
Gets instance from object
- Parameters:
obj (object) – UNO object.
- Raises:
NotSupportedError – If
obj
is not supported.- Returns:
Instance that represents Image crop.
- Return type:
Crop
- classmethod get_image_original_size(obj)[source]
- classmethod get_image_original_size(obj, **kwargs)
- classmethod get_image_original_size(obj, **kwargs)
Gets size from object in
1/100th mm
units.- Parameters:
obj (object) – UNO Object.
- Raises:
NotSupportedError – If
obj
is not supported.- Returns:
Size in
1/100th mm
units.- Return type:
- classmethod reset_image_original_size(obj)[source]
- classmethod reset_image_original_size(obj, **kwargs)
- classmethod reset_image_original_size(obj, **kwargs)
Resets the image to its original size. Resetting crop, scale and size.
- Parameters:
obj (object) – UNO Image Object
- Raises:
NotSupportedError – If
obj
is not supported.- Return type:
None
- property prop_crop_opt: CropOpt | None
Gets or Sets Crop Struct instance
- Return type:
CropOpt | None
- property prop_format_kind: FormatKind
Gets the kind of style
- Return type: