1

The following code generates a 300x100 image using a 100x100 tile as a source image:

for (my $i = 0; $i < 3; $i++) {
    $image->Read("filepath/100x100.png");
}

$result = $image->Montage(geometry=>'100x100',tile=>'3x1');

How do I reach the same result while only reading once from disk?

Dustin Paluch
  • 93
  • 1
  • 8

1 Answers1

2

It's not obvious from the docs, but you can add clones to the image sequence like this:

$image->Read("filepath/100x100.png");
$image->[1] = $image->[0]->Clone();
$image->[2] = $image->[0]->Clone();

$result = $image->Montage(geometry=>'100x100',tile=>'3x1');
Helios
  • 86
  • 5
  • Is there anything closer to this: `$image->Append($image->[0]->Clone());` So that I don't have to keep track of how many images have already been stored in the object? – Dustin Paluch Apr 25 '15 at 05:35
  • 1
    The `Image::Magick` object is just a blessed array, so you can use normal array operators, e.g. `push @$image, $image->[0]->Clone();`. You can get the last index with `$#$image`. – Helios Apr 25 '15 at 05:51