XML::SAX::SVGTransformer - SVG transformer
use XML::SAX::ParserFactory; use XML::SAX::SVGTransformer; use XML::SAX::Writer; my $output; my $writer = XML::SAX::Writer->new( Output => \$output, QuoteCharacter => '"', ); my $transformer = XML::SAX::SVGTransformer->new( Handler => $writer, Transform => 'rotate(90)', Width => 180, ); my $parser = XML::SAX::ParserFactory->parser( Handler => $transformer, ); $parser->parse_uri($file); say $transformer->info->{width};
This SAX handler adds a transform attribute to an SVG image to make it rotate, flip, or resize. You can also use this to extract the size information of the image.
Internally, this adds a comment to keep the initial image size, and a group with a transformation attribute to wrap everything in the outermost svg tag.
svg
Creates a handler. Options specific to this handler are:
An expected image width. The actual width may be different.
An xpected image height. The actual height may be different.
You can set both Width and Height, but you usually get a better result when you specify only one of them.
If set to true, aspect ratio is kept when both Width and Height are set.
A string to indicate how to transform the image. Valid values are
rotate(\d), flipx, flipy, matrix(\d \d \d \d \d \d).
rotate(\d)
flipx
flipy
matrix(\d \d \d \d \d \d)
This handler usually uses the same group if it finds a group it has added before. If SessionId is specified, it only reuses the group with the same id. Otherwise, it adds a new group to wrap the existing group.
Returns an informational hash reference.
Kenichi Ishigaki, <ishigaki@cpan.org>
This software is copyright (c) 2021 by Kenichi Ishigaki.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install XML::SAX::SVGTransformer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XML::SAX::SVGTransformer
CPAN shell
perl -MCPAN -e shell install XML::SAX::SVGTransformer
For more information on module installation, please visit the detailed CPAN module installation guide.