SVG-Optimiser

A python module to clear up SVG files, especially those created in Inkscape

Github星跟蹤圖

Python program to clean up SVG files, particularly those created by Inkscape or Illustrator

--- Current Functionality ---

Remove attributes

Remove attributes with a given name, e.g. remove 'id' attributes, which often aren't used.

Remove comments

Removes all comments.

Remove elements

Remove elements by their tag name.

Remove namespaces

Remove all attributes associated with a given namespace, e.g. remove 'sodipodi' attributes created by Inkscape.

Remove redundant groups

Move child elements outdside of group with no attributes, then delete group.

Set decimal places

Rewrite attributes to a given number of decimal places.
Strip out unnecessary trailing zeros.
  • Attributes
    • x, y, x1, y2, x2, y2
    • cx, cy
    • r, rx, ry
    • width, height
    • points
    • d

Apply transformations

Applies transformations to elements so the attribute can be removed.
  • Translation

    • In the form

      • comma: (12,34)
      • space(s): (12 34)
      • comma and space(s): (12, 34), (12 ,34), (12 , 34)
      • decimal: (1.2, 3.4)
      • negative: (-1.2, -3.4)
    • Shapes

      • line
      • rect
      • circle, ellipse
      • polyline, polygon
      • path (not fully tested)
      • g (not fully tested)
  • Scale

    • Shapes
      • path
      • rect

CSS stlying

Convert individual style attributes to CSS styling.
Remove default styles.

--- To Do ---

Remove namespaces

Remove xml namespace if possible

Groups

Remove unnecessary groups
Remove unnecessary text groups
Add groups in make styling and transforms more efficient

Transformations

  • Translation

    • In the form

      • single: (12)
    • Shapes

      • text
      • tspan
  • Rotation

    • Shapes
      • path
      • polyline/polygon
      • line
      • circle
      • rect -> polygon/path?
  • Scale

    • Shapes
      • polyline/polygon
      • line
      • circle -> ellipse?
  • SkewX and SkewY

    • Shapes
      • line
      • path
      • polyline/polygon
      • rect -> polygon/path?
      • circle -> path arc?
  • Matrix

    • Shapes
      • line
      • path
      • polyline/polygon
      • rect -> polygon/path?

CSS styling

Need to check whether style element already exists and whether class names already exist.
Ideally find most efficient way to class elements for styling.

License

概覽

名稱與所有者petercollingridge/SVG-Optimiser
主編程語言JavaScript
編程語言CSS (語言數: 4)
平台
許可證Other
發布數0
創建於2012-01-25 22:51:06
推送於2021-08-15 16:43:37
最后一次提交2017-03-17 12:47:48
星數182
關注者數16
派生數24
提交數66
已啟用問題?
問題數12
打開的問題數9
拉請求數3
打開的拉請求數5
關閉的拉請求數0
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?
去到頂部