zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgsquareutils module

SVG square/rectangle detection and elongation utilities.

zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgsquareutils._load_svg_tree(svg_input)[source]

Load SVG XML tree from either file path or cache hash.

Parameters:

svg_input – Either a file path or cache hash (starting with 'svg_')

Returns:

ElementTree object

Raises:
  • FileNotFoundError – If file doesn’t exist

  • ValueError – If cache hash not found

  • ET.ParseError – If XML parsing fails

zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgsquareutils._create_backup(svg_path)[source]

Create a backup copy of the SVG file.

Returns:

Path to backup file or None on failure

zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgsquareutils._restore_from_backup(svg_path, backup_path)[source]

Restore SVG file from backup.

Returns:

True if successful, False otherwise

zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgsquareutils._cleanup_backup(backup_path)[source]

Remove backup file if it exists.

zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgsquareutils.is_square_svg(svg_path)[source]

Check if SVG contains a single rectangle element.

Returns:

True if SVG contains exactly one <rect> element, False otherwise

zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgsquareutils.get_rectangle_bounds(svg_path)[source]

Get rectangle bounds: (x, y, width, height).

Returns:

Tuple of (x, y, width, height) or None if not a rectangle

zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgsquareutils.elongate_square(svg_path, scale_x, scale_y)[source]

Elongate rectangle by scaling width and height from center.

Stores modified SVG in cache and returns cache hash.

Parameters:
  • svg_path – Path to SVG file (will be read but not modified)

  • scale_x – Multiplier for width (minimum 0.2)

  • scale_y – Multiplier for height (minimum 0.2)

Returns:

svg_{8_char_hex})

Return type:

Cache hash of modified SVG (format

Raises:
  • ValueError – If scale_x < 0.2 or scale_y < 0.2

  • Exception – If SVG parsing or modification fails

See Also

  • zooui/objects/mediaobjects/svgmediaobject - SVGMediaObject class

  • zooui/objects/mediaobjects/mediaobjectsutils/svg/svgcache/svgcache - SVG caching system