Brian Hann > Image-WordCloud-0.03 > Image::WordCloud

Download:
Image-WordCloud-0.03.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.03   Source  

NAME ^

Image::WordCloud - Create word cloud images

SYNOPSIS ^

        use Image::WordCloud;
        use File::Slurp;
        
        my $wc = Image::WordCloud->new();
        
        # Add the Gettysburg Address
        my $text = read_file('script/gettysburg.txt');
        $wc->words($text);
        
        # Create the word cloud as a GD image
        my $gd = $wc->cloud();
        
        open(my $fh, '>', 'gettysburg.png');
                binmode $fh;
                print $fh $gd->png();
        close($fh);
        
        # See examples/gettysburg.png for how the created image looks.
        # script/gettysburg.pl will create it
        
        # The calls can also be chained like so:
        my $text = read_file('script/gettysburg.txt');
        my $gd = Image::WordCloud->new()
                ->words($text)
                ->cloud();

Create "word cloud" images from a set of specified words, similar to http://wordle.net. Font size indicates the frequency with which a word is used.

Colors are generated randomly using Color::Scheme. Fonts can be specified or chosen randomly.

FUNCTIONS ^

new( ... )

Accepts a number of parameters to alter the image look.

words(\%words_to_use | \@words | @words_to_use | $words)

Takes either a hashref, arrayref, array or string.

If the argument is a hashref, keys are the words, values are their count. No further processing is done (we assume you've done it on your own).

If the argument is an array, arrayref, or string, the words are parsed to remove non-word characters and turn them lower-case.

cloud()

Make the word cloud. Returns a GD::Image.

        my $gd = Image::WordCloud->new()->words(qw/some words etc/)->cloud();
        
        # Spit out the wordlcoud as a PNG
        $gd->png;
        
        # ... or a jpeg
        $gd->jpg;
        
        # Get the dimensions
        $gd->width;
        $gd->height;
        
        # Or anything else you can do with a GD::Image object

add_stop_words(@words)

Add new stop words onto the list. Automatically puts words in lowercase.

width()

Return wordcloud image width

height()

Return wordcloud image height

AUTHOR ^

Brian Hann, <bhann at cpan.org>

BUGS ^

Please report any bugs or feature requests here https://github.com/c0bra/image-wordcloud-perl/issues. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT ^

You can find documentation for this module with the perldoc command.

    perldoc Image::WordCloud

You can also look for information at:

LICENSE AND COPYRIGHT ^

Copyright 2012 Brian Hann.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

syntax highlighting: