Hi Eric

As you can see from:

http://savage.net.au/ImageMagick.html

it's definitely possible.

All headings on my web site are generated with a Perl program and IM, and
use a fill which is an image tiled across the text, and the image happens
to be a set of little, round, coloured disks.

Here's the code:
=====><8=====
#!/usr/bin/perl
#
# Name:
#       text-tiled-with-image-2.pl.

# Purpose:
#       Replicate an example on this page:
#       http://www.cit.gu.edu.au/~anthony/graphics/imagick6/text/#size
#
# V 1.01 31-May-2006
# ------------------
# o Upgrade from ImageMagick V 5 to V 6.
#
# V 1.00 30-May-2006
# ------------------
# o Initial version
#
# Test environment:
#       OS: WinXP SP2
#       Web server: Apache/2.0.54
#       ImageMagick: V 6.2.7
#
# Input files:
#       o /homepage/pages/page-names.txt
#       o tile_disks.jpg from
#       http://www.cit.gu.edu.au/~anthony/graphics/imagick6/canvas/#tile
#
# Output files:
#       o N images, using input file /homepage/pages/page-names.txt
#               and using the text to generate the file name.
#
# Note:
#       o tab = 4 spaces || die.
#       o Text NOT reformatted to max 50 chars wide
#       (used when source to be converted to PDF)
#
# Author:
#       Ron Savage <[EMAIL PROTECTED]>
#       http://savage.net.au/ImageMagick.html
#
# Licence:
#       Australian copyright (c) 2006 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 Artistic License,
#       a copy of which is available at:
#       http://www.opensource.org/licenses/index.html

# References:
# o http://www.cit.gu.edu.au/~anthony/graphics/imagick6/text/#size
# o http://www.cit.gu.edu.au/~anthony/graphics/imagick6/canvas/#tile
# o http://www.cit.gu.edu.au/~anthony/graphics/imagick6/draw/#settings

use strict;
use warnings;

use FindBin::Real;
use Image::Magick;

# ------------------------------------------------

sub doit2it
{
        my($text, $format) = @_;

        # Prepare the background.

        my($image)      = Image::Magick -> new(size => '800x120');
        my($result)     = $image -> Read('xc:black');

        die $result if $result;

        # Prepare the tile.

        my($tile)       = Image::Magick -> new();
        $result         = $tile -> Read(FindBin::Real::Bin() . 
'/tile_disks.jpg');

        die $result if $result;

        # Draw the text onto the background.
        # Note: The tile option automagically uses an image as the fill option. 
See:
        # http://www.cit.gu.edu.au/~anthony/graphics/imagick6/canvas/#tile

        $result = $image -> Draw
        (
                primitive       => 'text',
                points          => "20, 80 $text",
                tile            => $tile,
                stroke          => 'white',
                font            => 'Carolingia-(BigfooT)--Normal',
                pointsize       => 100,
        );

        die $result if $result;

        # Trim the image.

        $result = $image -> Trim();

        die $result if $result;

        # Expand the background, just to make the image prettier.

        $result = $image -> Border(fill => 'black', geometry => '10x10');

        die $result if $result;

        # Save the image.

        my($output_file_name) = FindBin::Real::Bin() . "/$text.$format";

        # Warning: This call does not work if it appears just after
Read('xc:black').

        $result = $image -> Transparent(color => 'black');

        die $result if $result;

        $result = $image -> Write($output_file_name);

        die $result if $result;

        print "Wrote $output_file_name. \n";

}       # End of doit2it.

# ------------------------------------------------

# Report ImageMagick version.

print "Image::Magick V $Image::Magick::VERSION. \n";

# Turn all the names of the pages of my web site into files.

my($input_file_name) = '/homepage/pages/page-names.txt';

open(INX, $input_file_name) || die("Can't open($input_file_name): $!");
my(@heading) = <INX>;
close INX;
chomp @heading;

for (@heading)
{
        doit2it($_ eq 'index' ? 'Home' : $_, 'png');
}

print "Finished. \n";
=====><8=====
-- 
Ron Savage
[EMAIL PROTECTED]
http://savage.net.au/
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to