simplest montage

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
gitparade
Posts: 2
Joined: 2011-05-31T13:31:37-07:00
Authentication code: 8675308

simplest montage

Post by gitparade »

I'm trying to recreate the following command line with PerlMagick (from http://www.imagemagick.org/Usage/montage/#montage)

Code: Select all

montage balloon.gif medical.gif present.gif shading.gif montage.jpg
I would have thought that the following would be a PerlMagick recreation of it:

Code: Select all

#!/usr/bin/env perl

use strict;

use Cwd;

use Image::Magick;

sub montage {
	my $cwd = getcwd();

	my $montage = new Image::Magick;
	$montage -> Read($_[0], $_[1]);

	my $filename = sprintf "%s/my_montage", $cwd;

	$montage -> Montage();
	$montage -> Write($filename);
}

&montage($ARGV[0], $ARGV[1]);
However, this code does not work:
  • it produces an image called my_montage-0 instead of my_montage
  • it doesn't produce a the image that (pseudocode) montage $ARGV[0] $ARGV[1] my_montage would have produced on the command line
In case they're interesting, my system specs are:
This is perl, v5.10.1 (*) built for x86_64-linux-gnu-thread-multi
ImageMagick 6.5.7-8 2010-12-02 Q16
PerlMagick 7:6.5.7.8-1ubuntu1


:)
gitparade
Posts: 2
Joined: 2011-05-31T13:31:37-07:00
Authentication code: 8675308

Re: simplest montage

Post by gitparade »

Slaps forehead...
The file demo.pl that is included in the distribution made me realize that the following is what I was looking for:

Code: Select all

#!/usr/bin/env perl

use strict;

use Cwd;

use Image::Magick;

sub montage {
	my $cwd = getcwd();
	
	my $images = new Image::Magick;
	$images -> Read($_[0], $_[1]);
	
	my $filename = sprintf "%s/my_montage.png", $cwd;
	
	my $montage = $images -> Montage();
	$montage -> Write($filename);
}

&montage($ARGV[0], $ARGV[1]);
For some reason, the extension is required in the filename. The following line does not work:

Code: Select all

	my $filename = sprintf "%s/my_montage", $cwd;
Post Reply