<?xml version="1.0" encoding="windows-1252"?>
<node id="53891" title="Stalag '99 comic strip compiler" created="2001-01-24 03:49:37" updated="2005-08-11 04:10:49">
<type id="1748">
sourcecode</type>
<author id="13922">
strredwolf</author>
<data>
<field name="doctext">
&lt;code&gt;
#!/usr/bin/perl

# Take all in InRotation
# Scale them down
# Add the byline on top
# Save them to done

# Anything with a -c.png is a color pic, and should be save as a .jpg, not a
# .gif

$|=1;

use Image::Magick;

$byline=Image::Magick-&gt;new;
$byline-&gt;Read('StalagComicTitle.gif');

$from="./InRotaton";
$to="./done";

opendir(DIR,$from) || die "Something: $!";
@d = grep {/^\d+/} readdir(DIR);
closedir(DIR);

@d1=sort @d;

# print @d1;
# exit;

while(@d1)
{
	$f=shift @d1;
        print "Working on $f... ";
	$f =~ /^([^.]+)\./;
	$fo=$1; $color=0;
	$color++ if($f =~ /-c\.png$/);
	$fo .= ($color ? ".jpg" : ".gif" );

	$img = Image::Magick-&gt;new;
	$img-&gt;Set(size=&gt;"720x1024");
	$img-&gt;ReadImage("null:white");
	
	
	$src = Image::Magick-&gt;new;
	$src-&gt;Read("$from/$f");
	$src-&gt;Resize(geometry=&gt;"720x720",filter=&gt;"Cubic",blur=&gt;.5);
	($w,$h)=$src-&gt;Get('width','height');
	

	$h+=16;
	$img-&gt;Composite(compose=&gt;'Replace',image=&gt;$byline,x=&gt;0,y=&gt;0);
	$img-&gt;Composite(compose=&gt;'Replace',image=&gt;$src,x=&gt;0,y=&gt;16);
	$img-&gt;Crop(x=&gt;0,y=&gt;0,width=&gt;$w,height=&gt;$h);
	unless($color)
	{
	    $img-&gt;Quantize(colors=&gt;16);
	    $img-&gt;Write("$to/temp.pgm");
	    system "ppmtogif $to/temp.pgm &gt; $to/$fo";
	} else {
	    $img-&gt;Write("$to/$fo");
	}
	print "done.\n";
}
&lt;/code&gt;</field>
<field name="codedescription">
Takes every comic strip in ./InRotation, massage it, and put it into ./done.
Uses ImageMagick.
</field>
<field name="codecategory">
Graphics</field>
<field name="codeauthor">
[strredwolf]</field>
</data>
</node>
