Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Stalag '99 comic strip compiler

by strredwolf (Chaplain)
on Jan 24, 2001 at 08:49 UTC ( #53891=sourcecode: print w/replies, xml ) Need Help??
Category: Graphics
Author/Contact Info strredwolf
Description: Takes every comic strip in ./InRotation, massage it, and put it into ./done. Uses ImageMagick.
#!/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->new;
$byline->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->new;
    $img->Set(size=>"720x1024");
    $img->ReadImage("null:white");
    
    
    $src = Image::Magick->new;
    $src->Read("$from/$f");
    $src->Resize(geometry=>"720x720",filter=>"Cubic",blur=>.5);
    ($w,$h)=$src->Get('width','height');
    

    $h+=16;
    $img->Composite(compose=>'Replace',image=>$byline,x=>0,y=>0);
    $img->Composite(compose=>'Replace',image=>$src,x=>0,y=>16);
    $img->Crop(x=>0,y=>0,width=>$w,height=>$h);
    unless($color)
    {
        $img->Quantize(colors=>16);
        $img->Write("$to/temp.pgm");
        system "ppmtogif $to/temp.pgm > $to/$fo";
    } else {
        $img->Write("$to/$fo");
    }
    print "done.\n";
}
Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://53891]
help
Chatterbox?
[Corion]: Ooh, yes, yay ;-D
[Discipulus]: my backpack is ready for two nights in the mountains!
[Corion]: Discipulus: In the mountains during winter?
[choroba]: SHAttered

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2017-02-24 09:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (353 votes). Check out past polls.