| 1 | #!/usr/bin/perl |
| 2 | use v5.14; |
| 3 | use warnings; |
| 4 | |
| 5 | use Getopt::Long; |
| 6 | use SVG::SpriteMaker; |
| 7 | |
| 8 | my $prefix = 'sprite'; |
| 9 | my $out; |
| 10 | |
| 11 | GetOptions( |
| 12 | 'prefix|p=s' => \$prefix, |
| 13 | 'output|out|o=s' => \$out, |
| 14 | ); |
| 15 | |
| 16 | my $sprite = make_sprite $prefix, @ARGV; |
| 17 | if ($out) { |
| 18 | open my $fh, '>', $out; |
| 19 | select $fh; |
| 20 | } |
| 21 | say $sprite->xmlify; |
| 22 | |
| 23 | __END__ |
| 24 | |
| 25 | =encoding utf-8 |
| 26 | |
| 27 | =head1 NAME |
| 28 | |
| 29 | svg-spritemaker - Combine several SVG images into a single SVG sprite |
| 30 | |
| 31 | =head1 SYNOPSIS |
| 32 | |
| 33 | svg-spritemaker [-o OUTPUT] [-p PREFIX] FILE... |
| 34 | |
| 35 | svg-spritemaker a.svg b.svg > sprite.svg # Standard usage |
| 36 | svg-spritemaker -p img a.svg b.svg > sprite.svg # Custom prefix |
| 37 | svg-spritemaker -o sprite.svg dir/*.svg # Output file |
| 38 | svg-spritemaker --prefix=logo --output=logos.svg logos/* # Long options |
| 39 | |
| 40 | =head1 DESCRIPTION |
| 41 | |
| 42 | svg-spritemaker takes several SVG images and combines them into a |
| 43 | single SVG sprite. See L<SVG::SpriteMaker> for more information about |
| 44 | SVG sprites. |
| 45 | |
| 46 | =head1 OPTIONS |
| 47 | |
| 48 | =over |
| 49 | |
| 50 | =item B<-o> I<file>, B<--out>=I<file>, B<--output>=I<file> |
| 51 | |
| 52 | Write the sprite into the following file, overwriting it if necessary. |
| 53 | By default the sprite is written on STDOUT. |
| 54 | |
| 55 | =item B<-p> I<prefix>, B<--prefix>=I<prefix> |
| 56 | |
| 57 | Sets the prefix for the fragment identifiers. Default is C<sprite> |
| 58 | (which results in identifiers C<sprite-a>, C<sprite-b> for the first |
| 59 | example in the SYNOPSIS). |
| 60 | |
| 61 | =back |
| 62 | |
| 63 | If an ID is shared between two or more input files, this program will |
| 64 | try to rename each occurence except for the first one. This operation |
| 65 | might have false positives (attributes/cdatas that are mistakenly |
| 66 | identified to contain the ID-to-be-renamed) and false negatives |
| 67 | (attributes/cdatas that actually contain the ID-to-be-renamed but this |
| 68 | is missed by the module), and as such svg-spritemaker will warn if |
| 69 | duplicate IDs are detected. You can suppress this warning by setting |
| 70 | the C<SVG_SPRITEMAKER_NO_DUPLICATE_WARNINGS> environment variable to a |
| 71 | true value. |
| 72 | |
| 73 | =head1 SEE ALSO |
| 74 | |
| 75 | L<SVG::SpriteMaker>, L<https://css-tricks.com/svg-fragment-identifiers-work/> |
| 76 | |
| 77 | =head1 AUTHOR |
| 78 | |
| 79 | Marius Gavrilescu, E<lt>marius@ieval.roE<gt> |
| 80 | |
| 81 | =head1 COPYRIGHT AND LICENSE |
| 82 | |
| 83 | Copyright (C) 2015-2017 by Marius Gavrilescu |
| 84 | |
| 85 | This library is free software; you can redistribute it and/or modify |
| 86 | it under the same terms as Perl itself, either Perl version 5.20.2 or, |
| 87 | at your option, any later version of Perl 5 you may have available. |
| 88 | |
| 89 | |
| 90 | =cut |