Image-Magick-CommandParser
view release on metacpan or search on metacpan
Changelog.ini view on Meta::CPAN
[Module]
Name=Image::Magick::CommandParser
Changelog.Creator=Module::Metadata::Changes V 2.11
Changelog.Parser=Config::IniFiles V 2.88
[V 1.04]
Date=2016-08-14T11:33:00
Comments= <<EOT
- Stop using Test::Stream. Use Test::More shipped in the Test::Simple distro.
See RT#116933. Thanx to Chad Granum.
- Update version #s in pre-reqs.
- Adopt new repo structure. For details, see
Revision history for Perl extension Image::Magick::CommandParser.
1.04 2016-08-14T11:33:00
- Stop using Test::Stream. Use Test::More shipped in the Test::Simple distro.
See RT#116933. Thanx to Chad Granum.
- Update version #s in pre-reqs.
- Adopt new repo structure. For details, see
http://savage.net.au/Ron/html/My.Workflow.for.Building.Distros.html.
- Update .gitignore and MANIFEST.SKIP.
- Change licence from Artistic to Perl.
- Move File::Spec, File::Temp, Test::Pod and Test::Simple to TEST_REQUIRES within Makefile.PL.
Makefile.PL view on Meta::CPAN
clean =>
{
FILES => 'blib/* Makefile MANIFEST Image-Magick-CommandParser-*'
},
dist =>
{
COMPRESS => 'gzip',
SUFFIX => 'gz'
},
DISTNAME => 'Image-Magick-CommandParser',
NAME => 'Image::Magick::CommandParser',
PL_FILES => {},
PREREQ_PM =>
{
'Data::Section::Simple' => 0.07,
'File::Glob' => 0,
'File::Slurper' => 0.008,
'Getopt::Long' => 0,
'Log::Handler' => 0.88,
'Moo' => 2.002004,
'Set::Array' => 0.30,
README file for Image::Magick::CommandParser.
See also: Changes and Changelog.ini.
Warning: WinZip 8.1 and 9.0 both contain an 'accidental' bug which stops
them recognizing POSIX-style directory structures in valid tar files.
You are better off using a reliable tool such as InfoZip:
ftp://ftp.info-zip.org/pub/infozip/
1 Installing from a Unix-like distro
------------------------------------
lib/Image/Magick/CommandParser.pm view on Meta::CPAN
package Image::Magick::CommandParser;
use strict;
use warnings;
use warnings qw(FATAL utf8); # Fatalize encoding glitches.
use Data::Section::Simple 'get_data_section';
use File::Glob;
use File::Slurper 'read_lines';
lib/Image/Magick/CommandParser.pm view on Meta::CPAN
} # End of run.
# ------------------------------------------------
1;
=pod
=head1 NAME
C<Image::Magick::CommandParser> - Parse any command line acceptable to convert or mogrify
=head1 Synopsis
This is scripts/synopsis.pl:
#!/usr/bin/env perl
use strict;
use warnings;
use warnings qw(FATAL utf8);
use Image::Magick::CommandParser;
# ----------------------------------------------
my($command) = 'convert colors/*s*.png -append output.png';
my($processor) = Image::Magick::CommandParser -> new
(
command => $command,
maxlevel => 'notice',
);
$processor -> run;
print 'Input: ', $command, "\n";
print 'Result: ', $processor -> result, "\n";
With its output (after running in the distro dir, with access to colors/*.png):
Input: convert colors/*s*.png -append output.png
Result: convert colors/fuchsia.png colors/silver.png -append output.png
=head1 Description
C<Image::Magick::CommandParser> is a stand-alone parser for command lines acceptable to the
L<Imagemagick|https://imagemagick.org> programs C<convert> and C<mogrify>.
It aims to handle all constructs supported by Imagemagick itself, but it's vital to understand
that this module does not use any component of Imagemagick. Hence the I<stand-alone> just above.
In particular the output is a stack, accessible via the C<< $object -> stack >> method, which
returns an array of hashrefs.
The stack is managed by an object of type L<Set::Array>. See the L</FAQ> for details.
lib/Image/Magick/CommandParser.pm view on Meta::CPAN
=back
Imagemagick has a web page, L<http://imagemagick.org/script/command-line-processing.php>, dedicated
to the features available in its command line processing code. Please report any cases where this
module does not support one of those features. But see L</Trouble-shooting> before reporting an
issue, since there I list a few special cases.
=head1 Installation
Install C<Image::Magick::CommandParser> as you would for any C<Perl> module:
Run:
cpanm Image::Magick::CommandParser
or run:
sudo cpan Image::Magick::CommandParser
or unpack the distro, and then:
perl Makefile.PL
make (or dmake or nmake)
make test
make install
=head1 Constructor and Initialization
Call C<new()> as C<< my($parser) = Image::Magick::CommandParser -> new(k1 => v1, k2 => v2, ...) >>.
It returns a new object of type C<Image::Magick::CommandParser>.
Key-value pairs accepted in the parameter list (see also the corresponding methods
[e.g. L</command([$string])>]):
=over 4
=item o command => $string
The command string to process.
lib/Image/Magick/CommandParser.pm view on Meta::CPAN
The way L<Set::FA::Element> was designed, it will not move from a state to the same state when the
input matches. So, to trigger the entry or exit subs, I have to rock back-and-forth between 2
states which are more-or-less identical.
=head1 Trouble-shooting
=head2 Installation failure
I had a failure when installing the module on my laptop for the 1st time. The problem was that,
somehow, during the installation of L<Image::Magick>, root had become the owner of a directory
under the control of perlbrew. To fix this, I had to do:
sudo chown ron:ron /home/ron/perl5/perlbrew/perls/perl-5.20.2/lib/site_perl/5.20.2/x86_64-linux/auto/Image/Magick
=head2 Regions specified as '@100000' are not supported
So, you must put the '@' at the end of the region:
convert magick:logo -resize '10000@' wiz10000.png
=head2 Frame references are not supported
So, this won't work:
convert 'images.gif[0]' image.png
=head1 See Also
L<Imager>
L<Image::Magick::Chart>
L<Image::Magick::PolyText>
L<Image::Magick::Tiler>
L<Set::Array>
L<Set::FA::Element>
=head1 Machine-Readable Change Log
The file Changes was converted into Changelog.ini by L<Module::Metadata::Changes>.
=head1 Version Numbers
lib/Image/Magick/CommandParser.pm view on Meta::CPAN
Version numbers < 1.00 represent development versions. From 1.00 up, they are production versions.
=head1 Repository
L<https://github.com/ronsavage/Image-Magick-CommandParser>
=head1 Support
Email the author, or log a bug on RT:
L<https://rt.cpan.org/Public/Dist/Display.html?Name=Image::Magick::CommandParser>.
=head1 Author
C<Image::Magick::CommandParser> was written by Ron Savage I<E<lt>ron@savage.net.auE<gt>> in 2016.
My homepage: L<http://savage.net.au/>
=head1 Copyright
Australian copyright (c) 2016, Ron Savage.
All Programs of mine are 'OSI Certified Open Source Software';
you can redistribute them and/or modify them under the terms of
The Perl License, a copy of which is available at:
scripts/process.pl view on Meta::CPAN
#!/usr/bin/env perl
use strict;
use warnings;
use warnings qw(FATAL utf8); # Fatalize encoding glitches.
use Getopt::Long;
use Image::Magick::CommandParser;
use Pod::Usage;
# -----------------------------------------------
my($option_parser) = Getopt::Long::Parser -> new();
my(%option);
if ($option_parser -> getoptions
scripts/process.pl view on Meta::CPAN
\%option,
'command=s',
'help',
'logger=s',
'maxlevel=s',
'minlevel=s',
) )
{
pod2usage(1) if ($option{'help'});
exit Image::Magick::CommandParser -> new(%option) -> run;
}
else
{
pod2usage(2);
}
__END__
=pod
=head1 NAME
process.pl - Test Image::Magick::CommandParser
=head1 SYNOPSIS
process.pl [options]
Options:
-command aString
-help
-logger aString
-maxlevel aString
scripts/synopsis.pl view on Meta::CPAN
#!/usr/bin/env perl
use strict;
use warnings;
use warnings qw(FATAL utf8);
use Image::Magick::CommandParser;
# ----------------------------------------------
my($command) = 'convert colors/*s*.png -append output.png';
my($processor) = Image::Magick::CommandParser -> new
(
command => $command,
maxlevel => 'notice',
);
$processor -> run;
print 'Input: ', $command, "\n";
print 'Result: ', $processor -> result, "\n";
use strict;
use warnings;
use File::Spec;
use File::Temp;
use Image::Magick::CommandParser;
use Test::More;
# ------------------------------------------------
my(@test) =
(
{
command => 'convert logo:',
count => 1,
glob => '',
},
{
command => 'convert magick:logo -size 320x85 gif:-',
count => 52,
glob => '',
},
);
my($limit) = shift || 0;
my($maxlevel) = shift || 'notice';
my($parser) = Image::Magick::CommandParser -> new(maxlevel => $maxlevel);
my($expected);
my($got);
my($result);
for my $test (@test)
{
# Use this trick to run the tests one-at-a-time. See scripts/test.sh.
next if ( ($limit > 0) && ($$test{count} != $limit) );
( run in 1.694 second using v1.01-cache-2.11-cpan-beeb90c9504 )