optimize_svg

Function optimize_svg 

Source
pub fn optimize_svg(
    input_path: &Path,
    output_path: &Path,
    _args: &Cli,
    _resized_img: Option<DynamicImage>,
) -> Result<()>
Expand description

Optimizes an SVG file by removing metadata, unused elements, and normalizing whitespace.

This function provides basic SVG optimization by:

  • Removing XML comments and unnecessary whitespace
  • Stripping editor metadata and inkscape/adobe attributes
  • Cleaning up empty elements and unused definitions
  • Normalizing path data formatting
  • Preserving visual rendering integrity

§Arguments

  • input_path - Path to the source SVG file
  • output_path - Path where the optimized SVG will be written
  • _args - CLI configuration (currently unused for SVG optimization)
  • _resized_img - Not applicable for SVG files (always None)

§Returns

Returns Ok(()) on successful optimization.

§Errors

Returns an error if:

  • File I/O operations fail (reading input or writing output)
  • Regular expression operations fail