view release on metacpan or search on metacpan
{
"abstract" : "Render a cladogram using Imager or Image::Magick",
"author" : [
"Ron Savage (ron@savage.net.au)"
],
"dynamic_config" : 1,
"generated_by" : "ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
---
abstract: 'Render a cladogram using Imager or Image::Magick'
author:
- 'Ron Savage (ron@savage.net.au)'
build_requires:
ExtUtils::MakeMaker: '0'
File::Spec: '0'
File::Temp: '0'
Test::Pod: '1.51'
Test::Simple: '1.302052'
configure_requires:
ExtUtils::MakeMaker: '0'
Makefile.PL view on Meta::CPAN
# ----------------
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
my(%params) =
(
($] ge '5.005') ?
(
AUTHOR => 'Ron Savage (ron@savage.net.au)',
ABSTRACT => 'Render a cladogram using Imager or Image::Magick',
) : (),
clean =>
{
FILES => 'blib/* Makefile MANIFEST Tree-Cladogram-*'
},
dist =>
{
COMPRESS => 'gzip',
SUFFIX => 'gz'
},
DISTNAME => 'Tree-Cladogram',
LICENSE => 'perl',
NAME => 'Tree::Cladogram',
PL_FILES => {},
PREREQ_PM =>
{
'File::Slurper' => 0.008,
'Getopt::Long' => 0,
#'Image::Magick' => 6.9.3, # Image::Magick is optional.
'Imager' => 1.004,
'Imager::Fill' => 1.012,
'Moo' => 2.000002,
'parent' => 0,
'Pod::Usage' => 1.67,
'strict' => 0,
'Tree::DAG_Node' => 1.27,
'Types::Standard' => 1.00000,
'warnings' => 0,
},
lib/Tree/Cladogram.pm view on Meta::CPAN
} # End of run.
# ------------------------------------------------
1;
=pod
=head1 NAME
C<Tree::Cladogram> - Render a cladogram using Imager or Image::Magick
=head1 Synopsis
This is scripts/imager.pl:
#!/usr/bin/env perl
use strict;
use warnings;
lib/Tree/Cladogram.pm view on Meta::CPAN
For information about cladograms, see L<https://en.wikipedia.org/wiki/Cladogram>.
For another sample of a cladogram, see
L<http://phenomena.nationalgeographic.com/2015/12/11/paleo-profile-the-smoke-hill-bird/>.
Sample input is shipped as data/*.clad.
The corresponding output is shipped as data/*.png, and is on-line:
L<wikipedia.01.clad output by Imager|http://savage.net.au/misc/wikipedia.01.png>
L<wikipedia.01.clad output by Image::Magick|http://savage.net.au/misc/wikipedia.02.png>
L<nationalgeographic.01.clad output by Imager|http://savage.net.au/misc/nationalgeographic.01.png>
L<nationalgeographic.01.clad output by Image::Magick|http://savage.net.au/misc/nationalgeographic.02.png>
=head1 Distributions
This module is available as a Unix-style distro (*.tgz).
See L<http://savage.net.au/Perl-modules/html/installing-a-module.html>
for help on unpacking and installing distros.
=head1 Installation
lib/Tree/Cladogram.pm view on Meta::CPAN
Specify the thickness of the branches.
Default: 3 (px).
=item o debug => $Boolean
Specify non-production effects.
Currently, the only extra effect is to draw fuchsia boxes around the leaf names.
Frankly, this helped me debug the L<Image::Magick> side of things.
Default: 0 (no extra effects).
=item o draw_frame => $Boolean
Specify that you want a frame around the image.
Default: 0 (no frame).
=item o final_x_step => $integer
lib/Tree/Cladogram.pm view on Meta::CPAN
=item o leaf_font_color => $string
Specify the font color of the name of each leaf.
Default: '#0000ff' (blue).
=item o leaf_font_file => $string
Specify the name of the font file to use for the names of the leaves.
You can use path names, as per the default, or - using Image::Magick -, you can just use the name
of the font, such as 'DejaVu-Sans-ExtraLight'.
Default: '/usr/share/fonts/truetype/freefont/FreeMono.ttf'.
=item o leaf_font_size => $integer
Specify the size of the text used for the name of each leaf.
Default: 16 (points).
lib/Tree/Cladogram.pm view on Meta::CPAN
Specify the distance from the left of the image to the left-most point at which something is drawn.
This also sets the right-hand margin.
Default: 15 (px).
=item o output_file => $string
Specify the name of the image file to write.
Image formats supported are anything supported by L<Imager> or L<Image::Magick>.
See the L</What image formats are supported?> for details.
Default: '' (no output).
=item o print_tree => $Boolean
Specify that you want to print the tree constructed by the code.
This option is really a debugging aid.
lib/Tree/Cladogram.pm view on Meta::CPAN
=item o title_font_color => $string
Specify the font color of the title.
Default: '#000000' (black).
=item o title_font_file => $string
Specify the name of the font file to use for the title.
You can use path names, as per the default, or - using Image::Magick -, you can just use the name
of the font, such as 'DejaVu-Sans-ExtraLight'.
Default: '/usr/share/fonts/truetype/freefont/FreeSansBold.ttf'.
=item o title_font_size => $integer
Specify the size of the text used for the name of the title.
Default: 16 (points).
lib/Tree/Cladogram.pm view on Meta::CPAN
=head2 leaf_font_color([$string])
Get or set the font color of the text used to draw leaf names.
C<leaf_font_color> is a parameter to L</new()>.
=head2 leaf_font_file([$string])
Get or set the name of the font file used for leaf names.
You can use path names, as per the default, or - using Image::Magick -, you can just use the name
of the font, such as 'DejaVu-Sans-ExtraLight'.
C<leaf_font_file> is a parameter to L</new()>.
=head2 leaf_font_size([$integer])
Get or set the size of the font used to draw leaf names.
C<leaf_font_size> is a parameter to L</new()>.
lib/Tree/Cladogram.pm view on Meta::CPAN
=head2 title_font_color([$string])
Get or set the font color of the text used to draw the title.
C<title_font_color> is a parameter to L</new()>.
=head2 title_font_file([$string])
Get or set the name of the font file used for the title.
You can use path names, as per the default, or - using Image::Magick -, you can just use the name
of the font, such as 'DejaVu-Sans-ExtraLight'.
C<title_font_file> is a parameter to L</new()>.
=head2 title_font_size([$integer])
Get or set the size of the font used to draw the title.
C<title_font_size> is a parameter to L</new()>.
lib/Tree/Cladogram.pm view on Meta::CPAN
=item o imager.sh
A convenient way to run imager.pl.
=item o pod2html.sh
A simple way for me to convert the docs into HTML.
=item o test.image.magick.pl
Outputs data/test.image.magick.png. I used this program to experiment with L<Image::Magick> while
converting Tree::Cladogram::Imager into Tree::Cladogram::ImageMagick.
=item o test.image.magick.sh
A convenient way to run test.image.magick.pl.
=back
=head2 Data files
lib/Tree/Cladogram.pm view on Meta::CPAN
=item o nationalgeographic.01.clad
This sample input file is discussed just below, at the start of the L</FAQ>.
=item o nationalgeographic.01.png
This is the output of rendering nationalgeographic.01.clad with L<Imager>.
=item o nationalgeographic.02.png
This is the output of rendering nationalgeographic.01.clad with L<Image::Magick>.
=item o test.image.magick.png
The is is output of scripts/test.image.magick.pl.
=item o wikipedia.01.clad
This sample input file is discussed just below, at the start of the L</FAQ>.
=item o wikipedia.01.png
This is the output of rendering wikipedia.01.clad with L<Imager>.
=item o wikipedia.02.png
This is the output of rendering wikipedia.01.clad with L<Image::Magick>.
=back
=head1 FAQ
=head2 What is the format of the input file?
Sample 1 - L<https://en.wikipedia.org/wiki/Cladogram>:
+---- Beetles
lib/Tree/Cladogram.pm view on Meta::CPAN
Parent Place Node
root above Beetles
root below 1
1 above Wasps, bees, ants
1 below 2
2 above Butterflies, moths
2 below Flies
Output: L<Using Imager|http://savage.net.au/misc/wikipedia.01.png> and
L<using Image::Magick|http://savage.net.au/misc/wikipedia.02.png>.
Sample 2 - L<http://phenomena.nationalgeographic.com/2015/12/11/paleo-profile-the-smoke-hill-bird/>:
+--- Archaeopterix lithographica
|
|
|
Root ---+ +--- Apsaravis ukhaana
| |
| |
lib/Tree/Cladogram.pm view on Meta::CPAN
9 above 10
9 below 11
10 above Brodavis varnei
10 below Brodavis baileyi
11 above Fumicollis hoffmani
11 below 12
12 above Parahesperornis alexi
12 below Hesperornis regalis
Output: L<Using Imager|http://savage.net.au/misc/nationalgeographic.01.png> and
L<using Image::Magick|http://savage.net.au/misc/nationalgeographic.02.png>.
File format:
=over 4
=item o Words and numbers on each line are tab separated
Oh, all right. You can use any number of spaces too, but why bother?
=item o There are 3 columns
lib/Tree/Cladogram.pm view on Meta::CPAN
=item o Use digits for the skeleton nodes' names
The code hides the name of nodes which match /^(\d+|root)$/.
=back
=head2 Which versions of the renderers did you use?
L<Imager> V 1.004.
L<Image::Magick> V 6.9.3-0 Q16.
For help installing Image::Magick under Debian, see
L<http://savage.net.au/ImageMagick/html/Installation.html>.
=head2 What image formats are supported?
My default install of L<Imager> lists:
bmp
ft2
ifs
png
pnm
raw
L<Image::Magick> supports a huge range of formats (221 actually). To list them, run
scripts/test.image.magick.pl. Note: This program writes to data/test.image.magick.png.
=head2 What colors are supported?
See L<Imager::Color> for Imager's docs on color. But you're probably better off using
L<Image::Magick>'s table mentioned next, since my module only accepts colors. It does not allow
you to provide an Imager::Color object as a parameter.
See L<Image::Magick colors|http://www.imagemagick.org/script/color.php> for a huge table of both
names and hex values.
=head2 What fonts are supported?
Check these directories:
=over
=item o /usr/local/share/fonts
lib/Tree/Cladogram.pm view on Meta::CPAN
=head2 How is overlap between leaves detected?
The process starts by calling the undocumented method C<_check_for_overlap()>.
=head1 See Also
L<Bio::Tree::Draw::Cladogram>
L<Imager>
L<Image::Magick>
L<Help installing Image::Magick|http://savage.net.au/ImageMagick/html/Installation.html>
L<Tree::DAG_Node>
=head1 Machine-Readable Change Log
The file Changes was converted into Changelog.ini by L<Module::Metadata::Changes>.
=head1 Version Numbers
Version numbers < 1.00 represent development versions. From 1.00 up, they are production versions.
lib/Tree/Cladogram/ImageMagick.pm view on Meta::CPAN
package Tree::Cladogram::ImageMagick;
use parent 'Tree::Cladogram';
use Image::Magick;
use Moo;
use Types::Standard qw/Int/;
has title_x =>
(
default => sub{return 0},
is => 'rw',
isa => Int,
lib/Tree/Cladogram/ImageMagick.pm view on Meta::CPAN
required => 0,
);
our $VERSION = '1.04';
# ------------------------------------------------
sub _calculate_leaf_name_bounds
{
my($self) = @_;
my($image) = Image::Magick -> new(size => '1 x 1');
my($result) = $image -> Read('canvas:white');
my($leaf_font_size) = $self -> leaf_font_size;
my($x_step) = $self -> x_step;
my($attributes);
my(@metrics);
my($x);
my($y);
$self -> root -> walk_down
lib/Tree/Cladogram/ImageMagick.pm view on Meta::CPAN
$self -> title_x(int( ($maximum_x - $metrics[11]) / 2) );
$self -> title_y($maximum_y - $self -> leaf_font_size);
} # End of _calculate_title_metrics.
# ------------------------------------------------
sub create_image
{
my($self, $maximum_x, $maximum_y) = @_;
my($image) = Image::Magick -> new(size => "$maximum_x x $maximum_y");
$image -> Read('canvas:white');
$self -> _calculate_title_metrics($image, $maximum_x, $maximum_y) if (length($self -> title) );
if ($self -> draw_frame)
{
# The advantage of Draw over Border is that the former
# draws /on/ the image, thereby not making it larger.
my(@x) = (0, ($maximum_x - 1), ($maximum_x - 1), 0);
lib/Tree/Cladogram/ImageMagick.pm view on Meta::CPAN
} # End of write.
# ------------------------------------------------
1;
=pod
=head1 NAME
C<Tree::Cladogram::ImageMagick> - Render a cladogram using Imager or Image::Magick
=head1 Synopsis
See L<Tree::Cladogram/Synopsis>.
=head1 Description
See L<Tree::Cladogram/Description>.
=head1 Distributions
lib/Tree/Cladogram/Imager.pm view on Meta::CPAN
} # End of write.
# ------------------------------------------------
1;
=pod
=head1 NAME
C<Tree::Cladogram::Imager> - Render a cladogram using Imager or Image::Magick
=head1 Synopsis
See L<Tree::Cladogram/Synopsis>.
=head1 Description
See L<Tree::Cladogram/Description>.
=head1 Distributions
scripts/Debian.font.list.pl view on Meta::CPAN
#!/usr/bin/env perl
use 5.018;
use strict;
use warnings;
use Image::Magick;
# ----------------
my($image) = Image::Magick -> new;
my(@fonts) = $image -> QueryFont;
my(@formats) = $image -> QueryFormat;
# Semi-random numbers depend on the default list of fonts
# installed /on my laptop/ under Debian stable V 8.2.
my(%symbolic_font) =
(
55 => 1,
56 => 1,
scripts/Debian.font.list.pl view on Meta::CPAN
my($font_count) = $#fonts;
my($font_size) = 40;
my($x) = 20;
my($y) = 0;
my($y_step) = $font_size + 5;
my(@size) = (1100, $y_step * ($font_count + 2) );
say "Image size: ($size[0] x $size[1])";
my($image) = Image::Magick -> new(size => "$size[0]x$size[1]");
my($result) = $image -> Read('canvas:white');
die $result if $result;
$result = $image -> Frame(fill => 'red', geometry => '2x2');
die $result if $result;
my($font);
scripts/image.magick.pl view on Meta::CPAN
{
pod2usage(2);
}
__END__
=pod
=head1 NAME
image.magick.pl - Read input text file and write cladogram image file using Image::Magick
=head1 DESCRIPTION
image.magick.pl plots a cladogram.
=head1 SYNOPSIS
image.magick.pl [options]
Options:
scripts/test.image.magick.pl view on Meta::CPAN
#!/usr/bin/env perl
#
# I'm using V 6.9.3.
# See http://savage.net.au/ImageMagick/html/Installation.html.
use strict;
use warnings;
use Image::Magick;
# ----------------
my($out_file_name) = shift || die "Usage: $0 output_file_name \n";
my($font_file) = '/usr/share/fonts/truetype/freefont/FreeMono.ttf';
my($font_size) = 16;
my($frame_color) = 'purple';
my($title) = 'The diversity of hesperornithiforms. From Bell and Chiappe, 2015';
my($maximum_x) = 1000;
my($maximum_y) = 100;
# Warning:
# o new(geometry => "${maximum_x}x$maximum_y") does not work.
# o new(width => $maximum_x, height => $maximum_y) does not work.
# o new() and Set(geometry => "${maximum_x}x$maximum_y") does not work.
# o new() and Set (width => $maximum_x, height => $maximum_y) does not work.
# But:
# o new(size => "${maximum_x}x$maximum_y") does work.
# o new() and Set(size => "${maximum_x}x$maximum_y") does work.
my($image) = Image::Magick -> new(size => "$maximum_x x $maximum_y");
print "Created image of size ($maximum_x, $maximum_y). \n";
my(@formats) = $image -> QueryFormat;
print "Image formats supported (Count: @{[$#formats + 1]}): \n", join("\n", @formats), ". \n";
# Warning:
# The following line is mandatory before the code below will work.
# Of course, the color does not have to be white.