Text-Convert-ToImage

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN

use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
    'ABSTRACT'        => 'Simple Text to Image Conversion Tool',
    NAME              => 'Text::Convert::ToImage',
    VERSION_FROM      => 'lib/Text/Convert/ToImage.pm', # finds $VERSION
    PREREQ_PM         => 
        {
            "Image::Magick" => 5.44,
        }, # e.g., Module::Name => 1.1
    ($] >= 5.006 ?     ## Add these new keywords supported since 5.005
      (AUTHOR         => 'Harry Jackson <harry@hjackson.org>') : ()),
);

README  view on Meta::CPAN


   perl Makefile.PL
   make
   make test
   make install

DEPENDENCIES

This module requires these other modules and libraries:

  Image::Magick

COPYRIGHT AND LICENCE

Put the correct copyright and licence information here.

Copyright (C) 2004 by Harry Jackson

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.3 or,
at your option, any later version of Perl 5 you may have available.

lib/Text/Convert/ToImage.pm  view on Meta::CPAN

package Text::Convert::ToImage;
use 5.006001;
use strict;
use warnings;
use Carp;
use base qw( Image::Magick );
use vars qw( $VERSION $LEGAL_ATTRIBUTES );
our $VERSION = sprintf("%d.%02d", q$Revision: 0.00 $ =~ /(\d+)\.(\d+)/);

our $LEGAL_ATTRIBUTES = {
    LINE_HEIGHT => 18,
    LINE_LENGTH => 100,
    OUTPUT_FILE => 'www.hjackson.org',
    IMAGE_EXT   => 'png',
    POINT_SIZE  => 12,
    TEXT        => 'http://www.hjackson.org',

lib/Text/Convert/ToImage.pm  view on Meta::CPAN

        *$lc_field = sub { 
            my $self = shift;
            return $self->(uc $field, @_);
        };      
    }
    while ( my ($key, $val) = each %{ $config }) {
        $key = lc($key);
        $self->$key($val);
    }
    unless( ref($self->magick()) ) {
        my $magick = Image::Magick->new() || die "Unable to create Image::Magick Object $!";
        $self->magick( $magick );
    } 
}



sub _get_metrics {
    my ($self, $filename) = @_;
    
    if(ref($filename) ne 'GLOB') {

lib/Text/Convert/ToImage.pm  view on Meta::CPAN

module use it then I will write some tests for it.

At the moment I have been using it top obfuscate emails and not much else. A demo
can be found at L<http://www.hjackson.org/cgi-bin/tools/email.pl>

There are some undocumented features to this module and they are this way because I
have not tested to see if they work yet. 

=head1 SEE ALSO

L<Image::Magick>

=head1 AUTHOR

Harry Jackson

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2005 by Harry Jackson

This library is free software; you can redistribute it and/or modify

lib/Text/Convert/ToImage.pm~  view on Meta::CPAN

package Text::Convert::ToImage;
use 5.008003;
use strict;
use warnings;
#use baseImage::Magick;
use base qw( Image::Magick );
# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.

# This allows declaration	use Text::Convert::ToImage ':all';
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
# will save memory.
use vars qw( $VERSION $LEGAL_ATTRIBUTES );
our $VERSION = sprintf("%d.%02d", q$Revision: 0.00 $ =~ /(\d+)\.(\d+)/);

lib/Text/Convert/ToImage.pm~  view on Meta::CPAN

        *$lc_field = sub { 
            my $self = shift;
            return $self->(uc $field, @_);
        };      
    }
    while ( my ($key, $val) = each %{ $config }) {
        $key = lc($key);
        $self->$key($val);
    }
    # This allows a Develpoer to pass in his own pre-createed object
    my $magick = Image::Magick->new() || die "Unable to create Image::Magick Object$!";
    $self->magick( $magick ) unless ($self->magick());
    
}

#----------------------------------------------------------
#
#
#
#----------------------------------------------------------
sub calculate {

lib/Text/Convert/ToImage.pm~  view on Meta::CPAN

sub obfuscate {
    my $self = shift;
}

__END__
my $point_size = 18;
my $length = length ($text);
#my $size = "size=>'". int($length * 5.5) . "x10'";
my $size = "size=>'". int($length * ($point_size / 2)) . "x" . ($point_size + 1) ."'";
print $size . "\n";
$q=Image::Magick->new();
#$q->Set(size=>'100x10');
$q->Set(eval $size);
#$q->Read('gradient:#00f685-#0083f8');
$q->Read('xc:white');
$q->Set(fill=>'green',background=>'gray',matte=>0);
#$q->Rotate(-90);
#$q->Raise('2x2');
#$q->Wave(5);

$q->Annotate(text=>$text,font=>'Generic.ttf', fill=>'black', gravity=>'Center',pointsize=>$point_size);

lib/Text/Convert/ToImage.pm~  view on Meta::CPAN

#my $file = <FH>;
#
#print OUT $file;

#$q->Write('win:');


__END__

#!/usr/bin/perl
use Image::Magick;

my($image, $p, $q);
$image = Image::Magick->new || die;
$image->Set(size=>'100x100');
$image->ReadImage('xc:white');
$image->Set('pixel[49,49]'=>'red');
$text = 'Works like magick!';
my $x = $image->Annotate(font=>'Generic.ttf', pointsize=>5, fill=>'black', text=>'$text');
print $x if $x;
$image->Write(filename=>'image.png', compression=>'None');





( run in 0.426 second using v1.01-cache-2.11-cpan-beeb90c9504 )