NAME
XML::SAX::SVGTransformer - SVG transformer
SYNOPSIS
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};
DESCRIPTION
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.
METHODS
new
Creates a handler. Options specific to this handler are:
- Width
-
An expected image width. The actual width may be different.
- Height
-
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.
- KeepAspectRatio
-
If set to true, aspect ratio is kept when both Width and Height are set.
- Transform
-
A string to indicate how to transform the image. Valid values are
rotate(\d)
,flipx
,flipy
,matrix(\d \d \d \d \d \d)
. - SessionId
-
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.
info
Returns an informational hash reference.
AUTHOR
Kenichi Ishigaki, <ishigaki@cpan.org>
COPYRIGHT AND LICENSE
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.