All pastes #754808 Raw Edit

Mine

public text v1 · immutable
#754808 ·published 2007-10-30 07:58 UTC
rendered paste body
#!/usr/bin/perl

#
# strbuilder
#
# Copyright (c) 2000 Eric Shepherd
#
# Please don't distribute without my written permission.
#
# Generate GIF files from strings, using the
# Apple IIgs font - Now it's FAA Runway Signs.
#

use GD;

my $str = $::ARGV[0];    # first parameter is the string
my $path = $::ARGV[1];   # second parameter is the path

my $strlen = length($str);
my $imWidth = $strlen*20;

# Create the new image - always 415 pixels wide

my $im = new GD::Image(415, 35);
$black = $im->colorAllocate(0, 0, 0);
$im->fill(20, 35, $black);

# Scan the string

my $i = 0;
my $x = 3 + ($imWidth-20);

for ($i = 0; $i < $strlen; $i++) {
    # figure out which image file to load
    my $letter = chop($str);
    my $imagenum = 0;

#    if ($letter ge '@' && $letter le '_') {
#	$imagenum = ord($letter) - 64;
#    } elsif ($letter ge ' ' && $letter le '?') {
#	$imagenum = ord($letter);
#    } elsif ($letter ge '`' && $letter le '~') {
#	$imagenum = ord($letter);
#   }

$imagenum = ord($letter);

    # read the letter image file

    warn $imagenum;
    next unless -f "normal/norm$imagenum.png";
    open (PNG, "normal/norm$imagenum.png") || die "$!";
    my $letterImage = newFromPng GD::Image(PNG) || die;
    close PNG;
    print ("Width: %s, Height: %s\n", $gd->width, $height);
    # copy it into the new image

#copyResized(sourceImage,dstX,dstY,srcX,srcY,destW,destH,srcW,srcH) object method
#This method is similar to copy() but allows you to choose different sizes for the source and destination rectangles. The source and destination rectangle's are specified independently by (srcW,srcH) and (destW,destH) respectively. copyResized() will stretch or shrink the image to accomodate the size requirements.

    $im->copyResized($letterImage, $x, 0, 0, 0, 20, 35, 20, 35);
    $x = $x - 20;
}

# Write the output file

open (OUTF, "> $path") || die;
binmode OUTF;
print OUTF $im->png;
close OUTF;