svg-ultralight 0.45.6__py3-none-any.whl → 0.46.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of svg-ultralight might be problematic. Click here for more details.

@@ -32,6 +32,7 @@ from lxml import etree
32
32
 
33
33
  from svg_ultralight import NSMAP
34
34
  from svg_ultralight.bounding_boxes.bound_helpers import bbox_dict
35
+ from svg_ultralight.bounding_boxes.type_bound_element import BoundElement
35
36
  from svg_ultralight.bounding_boxes.type_bounding_box import BoundingBox
36
37
  from svg_ultralight.constructors import new_element
37
38
 
@@ -113,11 +114,11 @@ def _get_svg_embedded_image_str(image: ImageType) -> str:
113
114
  return "data:image/png;base64," + base64_encoded_result_str
114
115
 
115
116
 
116
- def new_image_elem_in_bbox(
117
+ def new_image_blem(
117
118
  filename: str | os.PathLike[str],
118
119
  bbox: BoundingBox | None = None,
119
120
  center: tuple[float, float] | None = None,
120
- ) -> EtreeElement:
121
+ ) -> BoundElement:
121
122
  """Create a new svg image element inside a bounding box.
122
123
 
123
124
  :param filename: filename of source image
@@ -125,7 +126,7 @@ def new_image_elem_in_bbox(
125
126
  :param center: center point for cropping. Proportions of image width and image
126
127
  height, so the default value, (0.5, 0.5), is the true center of the image.
127
128
  (0.4, 0.5) would crop 20% off the right side of the image.
128
- :return: an etree image element with the cropped image embedded
129
+ :return: a BoundElement element with the cropped image embedded
129
130
  """
130
131
  image = Image.open(filename)
131
132
  if bbox is None:
@@ -135,4 +136,21 @@ def new_image_elem_in_bbox(
135
136
  svg_image.set(
136
137
  etree.QName(NSMAP["xlink"], "href"), _get_svg_embedded_image_str(image)
137
138
  )
138
- return svg_image
139
+ return BoundElement(svg_image, bbox)
140
+
141
+
142
+ def new_image_elem_in_bbox(
143
+ filename: str | os.PathLike[str],
144
+ bbox: BoundingBox | None = None,
145
+ center: tuple[float, float] | None = None,
146
+ ) -> EtreeElement:
147
+ """Create a new svg image element inside a bounding box.
148
+
149
+ :param filename: filename of source image
150
+ :param bbox: bounding box for the image
151
+ :param center: center point for cropping. Proportions of image width and image
152
+ height, so the default value, (0.5, 0.5), is the true center of the image.
153
+ (0.4, 0.5) would crop 20% off the right side of the image.
154
+ :return: an etree image element with the cropped image embedded
155
+ """
156
+ return new_image_blem(filename, bbox, center).elem
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: svg-ultralight
3
- Version: 0.45.6
3
+ Version: 0.46.0
4
4
  Summary: a sensible way to create svg files with Python
5
5
  Author-email: Shay Hill <shay_public@hotmail.com>
6
6
  License: MIT
@@ -1,7 +1,7 @@
1
1
  svg_ultralight/__init__.py,sha256=3YdTZfa0xUDrPCbOVyx39D9ENks-JEtsi9DFZzvaTf0,2755
2
2
  svg_ultralight/animate.py,sha256=SMcQkeWAP9dD08Iyzy9qGG8Qk1p-14WfrB7WSN8Pj_4,1133
3
3
  svg_ultralight/attrib_hints.py,sha256=oCF20eG06vg2Tuapk1A14ovN7ZqZoZ43d-um_Zh0BPs,418
4
- svg_ultralight/image_ops.py,sha256=fFztGYHVunyS4ipdW4uafXctfjzLs-m6hHqKw0wDj00,4819
4
+ svg_ultralight/image_ops.py,sha256=M8E-aZ7SDYg_0wjQHJyo3GfJ-nYEE-fpRe__96jg1kU,5610
5
5
  svg_ultralight/inkscape.py,sha256=ySCxWnQwEt1sosa1b4mEkR-ugpfoAeg9gs1OLPS69iI,9597
6
6
  svg_ultralight/layout.py,sha256=7LV2I3u4EhqSc6ASvgwDtTZyV-Y1qt2wtvRtH2uKVAE,12799
7
7
  svg_ultralight/main.py,sha256=zaqWc5y9tsJoyNhpX2gIHKj1ZGEcfJebxNCcRQyoziU,7857
@@ -29,7 +29,7 @@ svg_ultralight/font_tools/font_info.py,sha256=-MEEM8Jslirevocv97RNRaArxaP3xeNiB7
29
29
  svg_ultralight/font_tools/globs.py,sha256=JdrrGMqDtD4WcY7YGUWV43DUW63RVev-x9vWqsQUhxU,119
30
30
  svg_ultralight/strings/__init__.py,sha256=BMGhF1pulscIgkiYvZLr6kPRR0L4lW0jUNFxkul4_EM,295
31
31
  svg_ultralight/strings/svg_strings.py,sha256=FQNxNmMkR2M-gCFo_woQKXLgCHi3ncUlRMiaRR_a9nQ,1978
32
- svg_ultralight-0.45.6.dist-info/METADATA,sha256=lizhXDXGBSAm-VJD-ygcGbZ3mkmGARO5ssLw56A9llw,9052
33
- svg_ultralight-0.45.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
- svg_ultralight-0.45.6.dist-info/top_level.txt,sha256=se-6yqM_0Yg5orJKvKWdjQZ4iR4G_EjhL7oRgju-fdY,15
35
- svg_ultralight-0.45.6.dist-info/RECORD,,
32
+ svg_ultralight-0.46.0.dist-info/METADATA,sha256=BVLEwDk-WWznBaZpW0KJkNJnsEnpnyqIVo2hm6HEWzA,9052
33
+ svg_ultralight-0.46.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
+ svg_ultralight-0.46.0.dist-info/top_level.txt,sha256=se-6yqM_0Yg5orJKvKWdjQZ4iR4G_EjhL7oRgju-fdY,15
35
+ svg_ultralight-0.46.0.dist-info/RECORD,,