#!/usr/bin/perl
#
# Name:
#	im-hax-vertical-shift-1.pl.
#
# Purpose:
#	Shift an image down N pixels.
#
# V 1.01 20-Feb-2002
# ------------------
# o Output to same dir as other hax
# o Report names of output files
#
# V 1.00 17-Jan-2002
# ------------------
# o Initial version
#
# Test environment:
#	OS: WinNT 4 SP 6a
#	Web server: Apache V 1.3.26
#	IM: V 5.4.7

#
# Input files:
#	None.
#
# Output files:
#	/apache/htdocs/im-hax-vertical-shift-1.png
#	/apache/htdocs/im-hax-vertical-shift-2.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($doc_root_name)		= '/apache/htdocs';
my($output_file_name_a)	=
	"$doc_root_name/im-hax-vertical-shift-1.png";
my($output_file_name_b)	=
	"$doc_root_name/im-hax-vertical-shift-2.png";
my($vertical_offset)	= shift || 50; # pixels.
my($width)				= 17;
my($height_1)			= 22;
my($height_2)			=
	$height_1 + $vertical_offset;
my($image_1)			=
	Image::Magick -> new
	(size => "${width}x$height_1"); # Remember:
my($image_2)			=			# No spaces
	Image::Magick -> new			# around the
	(size => "${width}x$height_2"); # 'x'.

my($result);

$result = $image_1 -> Read('xc:green');
warn $result if $result;
$result = $image_2 -> Read('xc:white');
warn $result if $result;

$result = $image_1 -> Border
(
	geometry	=> '1x1',
	fill		=> 'red',
);
warn $result if $result;
$result = $image_2 -> Border
(
	geometry	=> '1x1',
	fill		=> 'red',
);
warn $result if $result;

$result = $image_2 -> Composite
(
	compose	=> 'Over',
	image	=> $image_1,
	x		=> 0,
	y		=> $vertical_offset,
);
warn $result if $result;

$result = $image_1 -> Write($output_file_name_a);
warn $result if $result;

print "Wrote: $output_file_name_a. \n";

$result = $image_2 -> Write($output_file_name_b);
warn $result if $result;

print "Wrote: $output_file_name_b. \n";
