svg-ultralight 0.45.5__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,8 @@ 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
36
+ from svg_ultralight.bounding_boxes.type_bounding_box import BoundingBox
35
37
  from svg_ultralight.constructors import new_element
36
38
 
37
39
  if TYPE_CHECKING:
@@ -41,8 +43,6 @@ if TYPE_CHECKING:
41
43
  _Element as EtreeElement, # pyright: ignore [reportPrivateUsage]
42
44
  )
43
45
 
44
- from svg_ultralight.bounding_boxes.type_bounding_box import BoundingBox
45
-
46
46
 
47
47
  def _symmetric_crop(
48
48
  image: ImageType, center: tuple[float, float] | None = None
@@ -114,11 +114,11 @@ def _get_svg_embedded_image_str(image: ImageType) -> str:
114
114
  return "data:image/png;base64," + base64_encoded_result_str
115
115
 
116
116
 
117
- def new_image_elem_in_bbox(
117
+ def new_image_blem(
118
118
  filename: str | os.PathLike[str],
119
119
  bbox: BoundingBox | None = None,
120
120
  center: tuple[float, float] | None = None,
121
- ) -> EtreeElement:
121
+ ) -> BoundElement:
122
122
  """Create a new svg image element inside a bounding box.
123
123
 
124
124
  :param filename: filename of source image
@@ -126,7 +126,7 @@ def new_image_elem_in_bbox(
126
126
  :param center: center point for cropping. Proportions of image width and image
127
127
  height, so the default value, (0.5, 0.5), is the true center of the image.
128
128
  (0.4, 0.5) would crop 20% off the right side of the image.
129
- :return: an etree image element with the cropped image embedded
129
+ :return: a BoundElement element with the cropped image embedded
130
130
  """
131
131
  image = Image.open(filename)
132
132
  if bbox is None:
@@ -136,4 +136,21 @@ def new_image_elem_in_bbox(
136
136
  svg_image.set(
137
137
  etree.QName(NSMAP["xlink"], "href"), _get_svg_embedded_image_str(image)
138
138
  )
139
- 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.5
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=6xw0os6O3mRgaZOclb0bvGdy3EjQR9rCwEFP_UhvQV0,4825
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.5.dist-info/METADATA,sha256=Nen5S_7cPJWIcbZCyrQGuvqkADk1g6-D7HsBmfiso7I,9052
33
- svg_ultralight-0.45.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
- svg_ultralight-0.45.5.dist-info/top_level.txt,sha256=se-6yqM_0Yg5orJKvKWdjQZ4iR4G_EjhL7oRgju-fdY,15
35
- svg_ultralight-0.45.5.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,,