#!/usr/bin/perl
#
# Name:
#	im-hax-montage-1.pl.
#
# Purpose:
#	Demonstrate the Montage method.
#
# V 1.02 06-Jun-2006
# ------------------
# o Upgrade ImageMagick from V 5.4.7 to V 6.2.8
# o Re-check all hax
#
# V 1.01 20-Feb-2002
# ------------------
# o Output to same dir as other hax
#
# V 1.00 1-Oct-2001
# -----------------
# o Initial version
#
# Test environment:
#	OS: WinXP SP2
#	Web server: Apache/2.0.54
#	ImageMagick: V 6.2.8
#
# Input files:
#	o Generic.ttf
#	o /apache/htdocs/im/logo.jpg
#	o /apache/htdocs/im/smile.gif
#
# Output files:
#	o /apache/htdocs/im-hax-montage-1.png
#
# Note:
#	o tab = 4 spaces || die.
#	o Text reformatted to max 50 chars wide
#		so source can be converted to PDF
#
# Author:
#	Ron Savage <ron@savage.net.au>
#	http://savage.net.au/ImageMagick.html
#
# Licence:
#	Copyright (c) 1999-2002 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

use strict;
use warnings;

use Image::Magick;

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

my($im_version) = $Image::Magick::VERSION;
print "Image::Magick V $im_version. \n";

my($doc_root_name)		= '/apache2/htdocs/im';
my($input_file_name_1)	=
	$doc_root_name . '/smile.gif';
my($input_file_name_2)	=
	$doc_root_name . '/logo.jpg';
my($output_file_name)	=
	$doc_root_name . '/im-hax-montage-1.png';
my($stack)				= Image::Magick -> new();
my($image)				= Image::Magick -> new();
my($result)				=
	$image -> Read($input_file_name_1);
warn $result if $result;

my($j)	= Image::Magick -> new();
$result	= $j -> Read($input_file_name_2);
warn $result if $result;

push(@$stack, $image);
push(@$stack, $j);

my($final) = $stack -> Montage
(
	title		=> 'model + smile',
	label		=> 'model,smile',
#	font		=> 'Generic.ttf',
	pointsize	=> 32,
	tile		=> '2x2',
	stroke		=> 'red',
	shadow		=> 'true',
	borderwidth	=> 2,
	frame		=> '2x2',
);

$result = $final -> Write($output_file_name);
warn $result if $result;
print "Success. Wrote $output_file_name. \n";
